home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / PredatorPrey / calc_draw_object.c < prev    next >
Text File  |  1996-06-22  |  90KB  |  2,613 lines

  1.             /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
  2.             /*                                                               */
  3.             /*                    Prototype HP15C Calculator                */
  4.             /*                    James C. Ullrey                            */
  5.             /*                    INRESCO                                    */
  6.             /*                    © 1990                                    */
  7.             /*                    Version    13.97a                            */
  8.             /*                                                               */
  9.             /*                    DRAW_OBJECT   SEGMENT                       */
  10.             /*                                                               */
  11.             /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
  12.  
  13.  
  14. /*****************************************************************/
  15. /*  I N C L U D E S
  16. /*****************************************************************/
  17.  
  18. #ifndef __C14__
  19. #include    "PredatorPrey.h"
  20. #endif
  21. #include "calc_draw_object.h"
  22. //#define        noShow
  23. /********************************************************************
  24. /*  G L O B A L   V A R I A B L E   D E C L A R A T I O N S
  25. /********************************************************************/
  26.  
  27. extern    WindowPtr    lastPtr;
  28. extern    Rect        gFirstCalcIcon,gSecondCalcIcon,gThirdCalcIcon;
  29. extern    Rect        gFourthCalcIcon,gFifthCalcIcon,gSixthCalcIcon;
  30. extern    WindowPtr    preyPtr;
  31.  
  32. /********************** draw_object **************************/
  33. void draw_object(WindowPtr wPtr,short n,Boolean spec)
  34.         /*    n was formerly index    */
  35. {        
  36.     short        obj_type,i,j,k,m;
  37.     short        _left,_top,_right,_bottom;
  38.     Handle        icon_hndl;
  39.     Point        offset;            /* amount the document has been scrolled    */
  40.     Rect        obj_rect, selector_rect;
  41.     PenState     pen_state;
  42.     WObjsHandle    w_objs_hndl;
  43.     PolyHandle    thePoly;
  44.     PolyHandle    otherPoly;
  45.     PolyHandle    thatPoly;
  46.     GrafPtr        oldPort;
  47.     PicHandle    gMissle;
  48.     long        xMPt,yMPt;
  49. //    Boolean        doPers = FALSE;
  50.     Boolean        doPers = TRUE;
  51.     Boolean        noShow = TRUE;
  52.     double_t    fL,xVan,yVan,negInvrsFL;
  53.     double_t    zScale;
  54.     //double_t    pers4Mat[4][4];
  55.     //double_t    pers8Mat[4][4];
  56.     //double_t    pers3Mat[4][4];
  57.     //double_t    newPers4Vect[4][4];
  58.     //double_t    newPers8Vect[8][4];
  59.     //double_t    newPers3Vect[8][4];
  60.     //double_t    preplot4[4][4];
  61.     
  62.     short        xFactor,yFactor;
  63.     
  64.     double_t        pers4Mat[4][4][4];
  65.     double_t        pers8Mat[8][4][4];
  66.     double_t        pers3Mat[3][4][4];
  67.     double_t        newPers4Vect[4][4];
  68.     double_t        newPers8Vect[8][4];
  69.     double_t        newPers3Vect[3][4];
  70.     double_t        preplot4[4][4];
  71.     double_t        preplot8[8][4];
  72.     double_t        preplot3[3][4];
  73.     double_t        Wtemp4[4];
  74.     double_t        Wtemp8[8];
  75.     double_t        Wtemp3[3];
  76.     double_t        xForm4[4][4];
  77.     double_t        xForm8[8][4];
  78.     double_t        xForm3[3][4];
  79.     double_t        VRPxform[4][4];
  80. /*************        Establish the size and location of the object    **************/
  81.  
  82.  
  83.     w_objs_hndl = (WObjsHandle)GetWRefCon(wPtr);
  84.     offset = (**w_objs_hndl).scrollAmount;
  85.  
  86.     //if((**w_objs_hndl).paletteSetting != BACKGRND_OBJ)
  87.     if(n <= MAX_OBJECTS)
  88.     {    
  89.         obj_rect = (**w_objs_hndl).object[n].bounds;
  90.         
  91.         if(!spec)    OffsetRect(&obj_rect, -offset.h, -offset.v);
  92.     
  93.         obj_type = (**w_objs_hndl).object[n].type;
  94.     
  95.  
  96. /*****    Outline "selected" objects in gray if window is active                ******/
  97.  
  98.  
  99.         if( ((wPtr == FrontWindow()) || (wPtr == lastPtr)) && ((**w_objs_hndl).object[n].selected != NO_OBJ))
  100.         {
  101.             GetPort(&oldPort );
  102.             SetPort(lastPtr);
  103.             GetPenState (&pen_state);
  104.             PenNormal();
  105.             PenSize(2,2);
  106.             //PenPat((PatPtr)gray);
  107.             PenPat(&qd.gray);
  108.             
  109.             FrameRect (&obj_rect);
  110.     
  111.     /*****    Put a small black "grow box" in lower right of framing rectangle    ******/    
  112.     
  113.             SetRect(&selector_rect,
  114.                     obj_rect.right  - 5,
  115.                     obj_rect.bottom - 5,
  116.                     obj_rect.right ,
  117.                     obj_rect.bottom);
  118.     
  119.             PenPat(&qd.black);
  120.             PaintRect(&selector_rect);
  121.             
  122.             SetPenState (&pen_state);
  123.             SetPort( oldPort );
  124.         }
  125.     }
  126.     else if(n == MAX_OBJECTS + 2)
  127.     {
  128.         if((**w_objs_hndl).hasTargets == TRUE)    obj_type = T_BACKGRND_OBJ;
  129.         else    obj_type = BACKGRND_OBJ;
  130.     }
  131.  
  132. /*************        Draw the object                                    **************/
  133.     GetPort(&oldPort );
  134.     if((**w_objs_hndl).isPrey)
  135.     {
  136.         SetPort(preyPtr);
  137.     }
  138.     else    SetPort(lastPtr);
  139.  
  140.     if(obj_type == CIRCLE_OBJ) FrameOval(&obj_rect);
  141.  
  142.     else if(obj_type == SQUARE_OBJ) FrameRect(&obj_rect);
  143.  
  144.     else if(obj_type == CUBE_OBJ)
  145.     {
  146.         thePoly = OpenPoly();
  147.         MoveTo((**w_objs_hndl).object[n]._3dPt[0].x_point -offset.h,
  148.                 (**w_objs_hndl).object[n]._3dPt[0].y_point -offset.v);
  149.         LineTo((**w_objs_hndl).object[n]._3dPt[1].x_point -offset.h,
  150.                 (**w_objs_hndl).object[n]._3dPt[1].y_point -offset.v);
  151.         LineTo((**w_objs_hndl).object[n]._3dPt[2].x_point -offset.h,
  152.                 (**w_objs_hndl).object[n]._3dPt[2].y_point -offset.v);
  153.         LineTo((**w_objs_hndl).object[n]._3dPt[3].x_point -offset.h,
  154.                 (**w_objs_hndl).object[n]._3dPt[3].y_point -offset.v);
  155.         LineTo((**w_objs_hndl).object[n]._3dPt[0].x_point -offset.h,
  156.                 (**w_objs_hndl).object[n]._3dPt[0].y_point -offset.v);
  157.         ClosePoly();
  158.         FillPoly( thePoly,&qd.black);
  159.         LineTo((**w_objs_hndl).object[n]._3dPt[4].x_point -offset.h,
  160.                 (**w_objs_hndl).object[n]._3dPt[4].y_point -offset.v);
  161.         LineTo((**w_objs_hndl).object[n]._3dPt[5].x_point -offset.h,
  162.                 (**w_objs_hndl).object[n]._3dPt[5].y_point -offset.v);
  163.         LineTo((**w_objs_hndl).object[n]._3dPt[6].x_point -offset.h,
  164.                 (**w_objs_hndl).object[n]._3dPt[6].y_point -offset.v);
  165.         LineTo((**w_objs_hndl).object[n]._3dPt[7].x_point -offset.h,
  166.                 (**w_objs_hndl).object[n]._3dPt[7].y_point -offset.v);
  167.         LineTo((**w_objs_hndl).object[n]._3dPt[4].x_point -offset.h,
  168.                 (**w_objs_hndl).object[n]._3dPt[4].y_point -offset.v);
  169.         MoveTo((**w_objs_hndl).object[n]._3dPt[1].x_point -offset.h,
  170.                 (**w_objs_hndl).object[n]._3dPt[1].y_point -offset.v);
  171.         LineTo((**w_objs_hndl).object[n]._3dPt[5].x_point -offset.h,
  172.                 (**w_objs_hndl).object[n]._3dPt[5].y_point -offset.v);
  173.         MoveTo((**w_objs_hndl).object[n]._3dPt[2].x_point -offset.h,
  174.                 (**w_objs_hndl).object[n]._3dPt[2].y_point -offset.v);
  175.         LineTo((**w_objs_hndl).object[n]._3dPt[6].x_point -offset.h,
  176.                 (**w_objs_hndl).object[n]._3dPt[6].y_point -offset.v);
  177.         MoveTo((**w_objs_hndl).object[n]._3dPt[3].x_point -offset.h,
  178.                 (**w_objs_hndl).object[n]._3dPt[3].y_point -offset.v);
  179.         LineTo((**w_objs_hndl).object[n]._3dPt[7].x_point -offset.h,
  180.                 (**w_objs_hndl).object[n]._3dPt[7].y_point -offset.v);
  181.     }
  182.     else if(obj_type == HOUSE_OBJ /*|| obj_type == ARMD_HOUSE3_OBJ || obj_type == ARMD_HOUSE2_OBJ || obj_type == ARMD_HOUSE1_OBJ*/ )
  183.     {
  184.         MoveTo((**w_objs_hndl).object[n]._3dPt[0].x_point -offset.h,
  185.                 (**w_objs_hndl).object[n]._3dPt[0].y_point -offset.v);
  186.         LineTo((**w_objs_hndl).object[n]._3dPt[1].x_point -offset.h,
  187.                 (**w_objs_hndl).object[n]._3dPt[1].y_point -offset.v);
  188.         LineTo((**w_objs_hndl).object[n]._3dPt[2].x_point -offset.h,
  189.                 (**w_objs_hndl).object[n]._3dPt[2].y_point -offset.v);
  190.         LineTo((**w_objs_hndl).object[n]._3dPt[3].x_point -offset.h,
  191.                 (**w_objs_hndl).object[n]._3dPt[3].y_point -offset.v);
  192.         LineTo((**w_objs_hndl).object[n]._3dPt[4].x_point -offset.h,
  193.                 (**w_objs_hndl).object[n]._3dPt[4].y_point -offset.v);
  194.         LineTo((**w_objs_hndl).object[n]._3dPt[0].x_point -offset.h,
  195.                 (**w_objs_hndl).object[n]._3dPt[0].y_point -offset.v);
  196.         MoveTo((**w_objs_hndl).object[n]._3dPt[5].x_point -offset.h,
  197.                 (**w_objs_hndl).object[n]._3dPt[5].y_point -offset.v);
  198.         LineTo((**w_objs_hndl).object[n]._3dPt[6].x_point -offset.h,
  199.                 (**w_objs_hndl).object[n]._3dPt[6].y_point -offset.v);
  200.         LineTo((**w_objs_hndl).object[n]._3dPt[7].x_point -offset.h,
  201.                 (**w_objs_hndl).object[n]._3dPt[7].y_point -offset.v);
  202.         LineTo((**w_objs_hndl).object[n]._3dPt[8].x_point -offset.h,
  203.                 (**w_objs_hndl).object[n]._3dPt[8].y_point -offset.v);
  204.         MoveTo((**w_objs_hndl).object[n]._3dPt[0].x_point -offset.h,
  205.                 (**w_objs_hndl).object[n]._3dPt[0].y_point -offset.v);
  206.         LineTo((**w_objs_hndl).object[n]._3dPt[9].x_point -offset.h,
  207.                 (**w_objs_hndl).object[n]._3dPt[9].y_point -offset.v);
  208.         LineTo((**w_objs_hndl).object[n]._3dPt[10].x_point -offset.h,
  209.                 (**w_objs_hndl).object[n]._3dPt[10].y_point -offset.v);
  210.         LineTo((**w_objs_hndl).object[n]._3dPt[11].x_point -offset.h,
  211.                 (**w_objs_hndl).object[n]._3dPt[11].y_point -offset.v);
  212.         LineTo((**w_objs_hndl).object[n]._3dPt[12].x_point -offset.h,
  213.                 (**w_objs_hndl).object[n]._3dPt[12].y_point -offset.v);
  214.         LineTo((**w_objs_hndl).object[n]._3dPt[13].x_point -offset.h,
  215.                 (**w_objs_hndl).object[n]._3dPt[13].y_point -offset.v);
  216.         LineTo((**w_objs_hndl).object[n]._3dPt[9].x_point -offset.h,
  217.                 (**w_objs_hndl).object[n]._3dPt[9].y_point -offset.v);
  218.         MoveTo((**w_objs_hndl).object[n]._3dPt[1].x_point -offset.h,
  219.                 (**w_objs_hndl).object[n]._3dPt[1].y_point -offset.v);
  220.         LineTo((**w_objs_hndl).object[n]._3dPt[10].x_point -offset.h,
  221.                 (**w_objs_hndl).object[n]._3dPt[10].y_point -offset.v);
  222.         MoveTo((**w_objs_hndl).object[n]._3dPt[2].x_point -offset.h,
  223.                 (**w_objs_hndl).object[n]._3dPt[2].y_point -offset.v);
  224.         LineTo((**w_objs_hndl).object[n]._3dPt[11].x_point -offset.h,
  225.                 (**w_objs_hndl).object[n]._3dPt[11].y_point -offset.v);
  226.         MoveTo((**w_objs_hndl).object[n]._3dPt[3].x_point -offset.h,
  227.                 (**w_objs_hndl).object[n]._3dPt[3].y_point -offset.v);
  228.         LineTo((**w_objs_hndl).object[n]._3dPt[12].x_point -offset.h,
  229.                 (**w_objs_hndl).object[n]._3dPt[12].y_point -offset.v);
  230.         MoveTo((**w_objs_hndl).object[n]._3dPt[4].x_point -offset.h,
  231.                 (**w_objs_hndl).object[n]._3dPt[4].y_point -offset.v);
  232.         LineTo((**w_objs_hndl).object[n]._3dPt[13].x_point -offset.h,
  233.                 (**w_objs_hndl).object[n]._3dPt[13].y_point -offset.v);
  234.         MoveTo((**w_objs_hndl).object[n]._3dPt[14].x_point -offset.h,
  235.                 (**w_objs_hndl).object[n]._3dPt[14].y_point -offset.v);
  236.         LineTo((**w_objs_hndl).object[n]._3dPt[15].x_point -offset.h,
  237.                 (**w_objs_hndl).object[n]._3dPt[15].y_point -offset.v);
  238.         LineTo((**w_objs_hndl).object[n]._3dPt[16].x_point -offset.h,
  239.                 (**w_objs_hndl).object[n]._3dPt[16].y_point -offset.v);
  240.         LineTo((**w_objs_hndl).object[n]._3dPt[17].x_point -offset.h,
  241.                 (**w_objs_hndl).object[n]._3dPt[17].y_point -offset.v);
  242.         LineTo((**w_objs_hndl).object[n]._3dPt[14].x_point -offset.h,
  243.                 (**w_objs_hndl).object[n]._3dPt[14].y_point -offset.v);
  244.         if((**w_objs_hndl).object[n].armed == TRUE)
  245.         {
  246.             MoveTo((**w_objs_hndl).object[n]._3dPt[18].x_point -offset.h,
  247.                 (**w_objs_hndl).object[n]._3dPt[18].y_point -offset.v);
  248.             LineTo((**w_objs_hndl).object[n]._3dPt[19].x_point -offset.h,
  249.                 (**w_objs_hndl).object[n]._3dPt[19].y_point -offset.v);
  250.             MoveTo((**w_objs_hndl).object[n]._3dPt[20].x_point -offset.h,
  251.                 (**w_objs_hndl).object[n]._3dPt[20].y_point -offset.v);
  252.             LineTo((**w_objs_hndl).object[n]._3dPt[21].x_point -offset.h,
  253.                 (**w_objs_hndl).object[n]._3dPt[21].y_point -offset.v);
  254.             if((**w_objs_hndl).armament_type >= 1 && (**w_objs_hndl).isPrey != 1)
  255.             {
  256.                 gMissle = GetPicture( 130 );
  257.                 xMPt = (**w_objs_hndl).object[n]._3dPt[0].x_point -offset.h;
  258.                 yMPt = (**w_objs_hndl).object[n]._3dPt[0].y_point -offset.v;
  259.                 SetRect(&(**w_objs_hndl).object[n].mStruct[0].mRect,xMPt-13,yMPt-12,xMPt-1,yMPt);
  260.                 SetRect(&(**w_objs_hndl).object[n].mStruct[1].mRect,xMPt+81,yMPt-12,xMPt+93,yMPt);
  261.                 SetRect(&(**w_objs_hndl).object[n].mStruct[2].mRect,xMPt-13,yMPt-26,xMPt-1,yMPt-14);
  262.                 SetRect(&(**w_objs_hndl).object[n].mStruct[3].mRect,xMPt+81,yMPt-26,xMPt+93,yMPt-14);
  263.                 SetRect(&(**w_objs_hndl).object[n].mStruct[4].mRect,xMPt-13,yMPt-40,xMPt-1,yMPt-28);
  264.                 SetRect(&(**w_objs_hndl).object[n].mStruct[5].mRect,xMPt+81,yMPt-40,xMPt+93,yMPt-28);
  265.                 SetRect(&(**w_objs_hndl).object[n].mStruct[6].mRect,xMPt-13,yMPt-54,xMPt-1,yMPt-42);
  266.                 SetRect(&(**w_objs_hndl).object[n].mStruct[7].mRect,xMPt+81,yMPt-54,xMPt+93,yMPt-42);
  267.                 SetRect(&(**w_objs_hndl).object[n].mStruct[8].mRect,xMPt-1,yMPt+1,xMPt+11,yMPt+13);
  268.                 SetRect(&(**w_objs_hndl).object[n].mStruct[9].mRect,xMPt+69,yMPt+1,xMPt+81,yMPt+13);
  269.                 SetRect(&(**w_objs_hndl).object[n].mStruct[10].mRect,xMPt+13,yMPt+1,xMPt+25,yMPt+13);
  270.                 SetRect(&(**w_objs_hndl).object[n].mStruct[11].mRect,xMPt+55,yMPt+1,xMPt+67,yMPt+13);
  271.                 SetRect(&(**w_objs_hndl).object[n].mStruct[12].mRect,xMPt+27,yMPt+1,xMPt+39,yMPt+13);
  272.                 SetRect(&(**w_objs_hndl).object[n].mStruct[13].mRect,xMPt+41,yMPt+1,xMPt+53,yMPt+13);
  273.                 for(i = 14 - (**w_objs_hndl).object[n].missles;i <= 13;i++)
  274.                 { 
  275.                     DrawPicture(gMissle,&(**w_objs_hndl).object[n].mStruct[i].mRect);
  276.                 }
  277.             }
  278.         }
  279.     }
  280.     else if(obj_type == BACKGRND_OBJ || obj_type == T_BACKGRND_OBJ)
  281.     {
  282.         fL = (**w_objs_hndl).focalLn;
  283.         negInvrsFL = fL;
  284.         xVan = (**w_objs_hndl).xvPt;
  285.         yVan = (**w_objs_hndl).yvPt;
  286.         
  287.         /*    initialize VRPxform    */
  288.         
  289.         for(i = 0;i <= 3;i++)
  290.         {
  291.             for(j = 0;j <= 3;j++)
  292.             {
  293.                 if (i == j)
  294.                     VRPxform[i][j] = 1;
  295.                 else
  296.                     VRPxform[i][j] = 0;
  297.             }
  298.         }
  299.         /*    set zScale    */
  300.         
  301.         zScale = 200.0;
  302.         
  303.         /*    set VRP    */
  304.         
  305.         VRPxform[0][3] = -1.0 * xVan;
  306.         VRPxform[1][3] = -1.0 * yVan;
  307.         
  308.         if(    (**w_objs_hndl).bg_object[0]._3dPt_BG[0].z_point < 0 &&
  309.             (**w_objs_hndl).bg_object[0]._3dPt_BG[1].z_point < 0 &&
  310.             (**w_objs_hndl).bg_object[0]._3dPt_BG[2].z_point < 0 &&
  311.             (**w_objs_hndl).bg_object[0]._3dPt_BG[3].z_point < 0)
  312.         {    
  313.             if(doPers)                                        /*    first tetrahedron    */
  314.             {
  315.                 for(j = 0;j <= 3;j++)    /*    0••3 cause 4 points in a tetrahedron    */
  316.                 {
  317.                     preplot4[j][0] = (**w_objs_hndl).bg_object[0]._3dPt_BG[j].x_point -offset.h;
  318.                     preplot4[j][1] = (**w_objs_hndl).bg_object[0]._3dPt_BG[j].y_point -offset.v;
  319.                     preplot4[j][2] = (**w_objs_hndl).bg_object[0]._3dPt_BG[j].z_point;
  320.                     preplot4[j][3] = (**w_objs_hndl).bg_object[0]._3dPt_BG[j].no_point;
  321.                 }                /*    got coords for all four points in this obj    */
  322.                 /*    transform to relative VRP    */
  323.                 for(j = 0;j <= 4;j++)
  324.                 {
  325.                     for(k = 0;k <= 3;k++)
  326.                     {
  327.                         xForm4[j][k] = 0.0;                
  328.                     }
  329.                 }
  330.                 
  331.                 for(j = 0;j <= 4;j++)
  332.                 {
  333.                     for(k = 0;k <= 3;k++)
  334.                     {
  335.                         for(i = 0;i <= 3;i++)
  336.                         {
  337.                             xForm4[j][k] += VRPxform[k][i] * preplot4[j][i];                
  338.                         }
  339.                     }
  340.                 }                
  341.                 /* first create and initialize persMat    */
  342.                 for(j = 0;j <= 3;j++)
  343.                 {
  344.                     for(k = 0;k <= 3;k++)
  345.                     {
  346.                         for(m = 0;m <= 3;m++)
  347.                         {
  348.                             if(m == k)    pers4Mat[j][k][m] = 1;
  349.                             else        pers4Mat[j][k][m] = 0;
  350.                         }
  351.                     }
  352.                 }
  353.                 for(j = 0;j <= 3;j++)        /*    cause four vertices in the object    */
  354.                 {
  355.                     Wtemp4[j] = (xForm4[j][2]) / zScale;                /*    tenth try    */
  356.                 }
  357.                 for(m = 0;m <= 3;m++)
  358.                 {
  359.                     for(k = 0;k <= 2;k++)
  360.                     {
  361.                         newPers4Vect[m][k] = 0;        /*    initialize    */
  362.                     }
  363.                     newPers4Vect[m][3] = 1;
  364.                 }
  365.                 for(m = 0;m <= 3;m++)
  366.                 {                                /*       *---------------- vertice point    */
  367.                                                 /*     |  *----------- row                */
  368.                     for(k = 0;k <= 2;k++)        /*       |  |  *-------- column            */
  369.                     {                            /*       v  v  v                            */
  370.                         newPers4Vect[m][k] = xForm4[m][k]/(Wtemp4[m]);
  371.                     }
  372.                 }                                            
  373.                 /*    transform back from VRP    */
  374.  
  375.                 VRPxform[0][3] = xVan;
  376.                 VRPxform[1][3] = yVan;
  377.                 
  378.                 for(j = 0;j <= 3;j++)
  379.                 {
  380.                     for(k = 0;k <= 3;k++)
  381.                     {
  382.                         xForm4[j][k] = 0;                
  383.                     }
  384.                 }
  385.                 for(j = 0;j <= 3;j++)
  386.                 {
  387.                     for(k = 0;k <= 3;k++)
  388.                     {
  389.                         for(i = 0;i <= 3;i++)
  390.                         {
  391.                             xForm4[j][k] += VRPxform[k][i] * newPers4Vect[j][i];                
  392.                         }
  393.                     }
  394.                 }
  395.                 for(j = 0;j <= 3;j++)
  396.                 {
  397.                     for(k = 0;k <= 3;k++)
  398.                     {
  399.                         newPers4Vect[j][k] = xForm4[j][k];
  400.                     }
  401.                 }
  402.                 thePoly = OpenPoly();
  403.                 MoveTo(newPers4Vect[0][0],newPers4Vect[0][1]);    /*    first tetrahedron    */
  404.                 LineTo(newPers4Vect[1][0],newPers4Vect[1][1]);
  405.                 LineTo(newPers4Vect[2][0],newPers4Vect[2][1]);
  406.                 LineTo(newPers4Vect[0][0],newPers4Vect[0][1]);
  407.                 ClosePoly();
  408.                 FillPoly( thePoly,&qd.black);
  409.  
  410.                 LineTo(newPers4Vect[3][0],newPers4Vect[3][1]);
  411.                 LineTo(newPers4Vect[1][0],newPers4Vect[1][1]);
  412.                 MoveTo(newPers4Vect[2][0],newPers4Vect[2][1]);
  413.                 LineTo(newPers4Vect[3][0],newPers4Vect[3][1]);
  414.             }
  415.             else    // if (!noShow)
  416.             {            
  417.                 MoveTo((**w_objs_hndl).bg_object[0]._3dPt_BG[0].x_point -offset.h,        /*    first tetrahedron    */
  418.                         (**w_objs_hndl).bg_object[0]._3dPt_BG[0].y_point -offset.v);
  419.                 LineTo((**w_objs_hndl).bg_object[0]._3dPt_BG[1].x_point -offset.h,
  420.                         (**w_objs_hndl).bg_object[0]._3dPt_BG[1].y_point -offset.v);
  421.                 LineTo((**w_objs_hndl).bg_object[0]._3dPt_BG[2].x_point -offset.h,
  422.                         (**w_objs_hndl).bg_object[0]._3dPt_BG[2].y_point -offset.v);
  423.                 LineTo((**w_objs_hndl).bg_object[0]._3dPt_BG[0].x_point -offset.h,
  424.                         (**w_objs_hndl).bg_object[0]._3dPt_BG[0].y_point -offset.v);
  425.                 LineTo((**w_objs_hndl).bg_object[0]._3dPt_BG[3].x_point -offset.h,
  426.                         (**w_objs_hndl).bg_object[0]._3dPt_BG[3].y_point -offset.v);
  427.                 LineTo((**w_objs_hndl).bg_object[0]._3dPt_BG[1].x_point -offset.h,
  428.                         (**w_objs_hndl).bg_object[0]._3dPt_BG[1].y_point -offset.v);
  429.                 MoveTo((**w_objs_hndl).bg_object[0]._3dPt_BG[2].x_point -offset.h,
  430.                         (**w_objs_hndl).bg_object[0]._3dPt_BG[2].y_point -offset.v);
  431.                 LineTo((**w_objs_hndl).bg_object[0]._3dPt_BG[3].x_point -offset.h,
  432.                         (**w_objs_hndl).bg_object[0]._3dPt_BG[3].y_point -offset.v);
  433.             }
  434.         }
  435.         if(    (**w_objs_hndl).bg_object[1]._3dPt_BG[0].z_point < 0 &&
  436.             (**w_objs_hndl).bg_object[1]._3dPt_BG[1].z_point < 0 &&
  437.             (**w_objs_hndl).bg_object[1]._3dPt_BG[2].z_point < 0 &&
  438.             (**w_objs_hndl).bg_object[1]._3dPt_BG[3].z_point < 0)
  439.         {
  440.             if(doPers)        /*    second tetrahedron    */
  441.             {
  442.                 for(j = 0;j <= 3;j++)    /*    0••3 cause 4 points in a tetrahedron    */
  443.                 {
  444.                     preplot4[j][0] = (**w_objs_hndl).bg_object[1]._3dPt_BG[j].x_point -offset.h;
  445.                     preplot4[j][1] = (**w_objs_hndl).bg_object[1]._3dPt_BG[j].y_point -offset.v;
  446.                     preplot4[j][2] = (**w_objs_hndl).bg_object[1]._3dPt_BG[j].z_point;
  447.                     preplot4[j][3] = (**w_objs_hndl).bg_object[1]._3dPt_BG[j].no_point;
  448.                 }
  449.                 /*    transform to relative VRP    */
  450.                 for(j = 0;j <= 3;j++)        /*    initialize xForm4    */
  451.                 {
  452.                     for(k = 0;k <= 3;k++)
  453.                     {
  454.                         xForm4[j][k] = 0.0;                
  455.                     }
  456.                 }
  457.                         /*    set VRP    */
  458.         
  459.                 VRPxform[0][3] = -1.0 * xVan;
  460.                 VRPxform[1][3] = -1.0 * yVan;
  461.  
  462.                 for(j = 0;j <= 3;j++)
  463.                 {
  464.                     for(k = 0;k <= 3;k++)
  465.                     {
  466.                         for(i = 0;i <= 3;i++)
  467.                         {
  468.                             xForm4[j][k] += VRPxform[k][i] * preplot4[j][i];                
  469.                         }
  470.                     }
  471.                 }                /* first create persMat    */
  472.                 for(j = 0;j <= 3;j++)
  473.                 {
  474.                     for(k = 0;k <= 3;k++)
  475.                     {
  476.                         for(m = 0;m <= 3;m++)
  477.                         {
  478.                             if(m == k)    pers4Mat[j][k][m] = 1;
  479.                             else        pers4Mat[j][k][m] = 0;
  480.                         }
  481.                     }
  482.                 }
  483.                 for(j = 0;j <= 3;j++)        /*    cause four vertices in the object    */
  484.                 {
  485.                     Wtemp4[j] = (xForm4[j][2]) / zScale;                /*    tenth try    */
  486.                 }
  487.                 for(m = 0;m <= 3;m++)
  488.                 {
  489.                     for(k = 0;k <= 2;k++)
  490.                     {
  491.                         newPers4Vect[m][k] = 0;
  492.                     }
  493.                     newPers4Vect[m][3] = 1;
  494.                 }
  495.                 for(m = 0;m <= 3;m++)            /*      *-------------- vertice point    */
  496.                 {                                /*    |  *----------- column        */
  497.                     for(k = 0;k <= 2;k++)        /*      |  |  *-------- vertice point */
  498.                     {                            /*      v  v  v                        */
  499.                         newPers4Vect[m][k] =   xForm4[m][k]/(Wtemp4[m]);
  500.                     }
  501.                 }
  502.                 /*    transform back from VRP    */
  503.  
  504.                 VRPxform[0][3] = xVan;
  505.                 VRPxform[1][3] = yVan;
  506.                 
  507.                 for(j = 0;j <= 3;j++)
  508.                 {
  509.                     for(k = 0;k <= 3;k++)
  510.                     {
  511.                         xForm4[j][k] = 0;                
  512.                     }
  513.                 }
  514.  
  515.                 for(j = 0;j <= 3;j++)
  516.                 {
  517.                     for(k = 0;k <= 3;k++)
  518.                     {
  519.                         for(i = 0;i <= 3;i++)
  520.                         {
  521.                             xForm4[j][k] += VRPxform[k][i] * newPers4Vect[j][i];                
  522.                         }
  523.                     }
  524.                 }
  525.                 for(j = 0;j <= 3;j++)
  526.                 {
  527.                     for(k = 0;k <= 3;k++)
  528.                     {
  529.                         newPers4Vect[j][k] = xForm4[j][k];
  530.                     }
  531.                 }
  532.                 MoveTo(newPers4Vect[0][0],newPers4Vect[0][1]);        /*    second tetrahedron    */
  533.                 
  534.                 LineTo(newPers4Vect[1][0],newPers4Vect[1][1]);
  535.                 LineTo(newPers4Vect[2][0],newPers4Vect[2][1]);
  536.                 thePoly = OpenPoly();
  537.                 LineTo(newPers4Vect[0][0],newPers4Vect[0][1]);
  538.                 LineTo(newPers4Vect[3][0],newPers4Vect[3][1]);
  539.                 LineTo(newPers4Vect[2][0],newPers4Vect[2][1]);
  540.                 ClosePoly();
  541.                 FillPoly( thePoly,&qd.gray);
  542.                 MoveTo(newPers4Vect[1][0],newPers4Vect[1][1]);
  543.                 LineTo(newPers4Vect[3][0],newPers4Vect[3][1]);
  544.             }
  545.             else    // if (!noShow)
  546.             {
  547.                 MoveTo((**w_objs_hndl).bg_object[1]._3dPt_BG[0].x_point -offset.h,        /*    second tetrahedron    */
  548.                         (**w_objs_hndl).bg_object[1]._3dPt_BG[0].y_point -offset.v);
  549.                 LineTo((**w_objs_hndl).bg_object[1]._3dPt_BG[1].x_point -offset.h,
  550.                         (**w_objs_hndl).bg_object[1]._3dPt_BG[1].y_point -offset.v);
  551.                 LineTo((**w_objs_hndl).bg_object[1]._3dPt_BG[2].x_point -offset.h,
  552.                         (**w_objs_hndl).bg_object[1]._3dPt_BG[2].y_point -offset.v);
  553.                 LineTo((**w_objs_hndl).bg_object[1]._3dPt_BG[0].x_point -offset.h,
  554.                         (**w_objs_hndl).bg_object[1]._3dPt_BG[0].y_point -offset.v);
  555.                 LineTo((**w_objs_hndl).bg_object[1]._3dPt_BG[3].x_point -offset.h,
  556.                         (**w_objs_hndl).bg_object[1]._3dPt_BG[3].y_point -offset.v);
  557.                 LineTo((**w_objs_hndl).bg_object[1]._3dPt_BG[1].x_point -offset.h,
  558.                         (**w_objs_hndl).bg_object[1]._3dPt_BG[1].y_point -offset.v);
  559.                 MoveTo((**w_objs_hndl).bg_object[1]._3dPt_BG[2].x_point -offset.h,
  560.                         (**w_objs_hndl).bg_object[1]._3dPt_BG[2].y_point -offset.v);
  561.                 LineTo((**w_objs_hndl).bg_object[1]._3dPt_BG[3].x_point -offset.h,
  562.                         (**w_objs_hndl).bg_object[1]._3dPt_BG[3].y_point -offset.v);
  563.             }
  564.         }
  565.         if(    (**w_objs_hndl).bg_object[2]._3dPt_BG[0].z_point < 0 &&
  566.             (**w_objs_hndl).bg_object[2]._3dPt_BG[1].z_point < 0 &&
  567.             (**w_objs_hndl).bg_object[2]._3dPt_BG[2].z_point < 0 &&
  568.             (**w_objs_hndl).bg_object[2]._3dPt_BG[3].z_point < 0)
  569.         {
  570.             if(doPers)
  571.             {
  572.                 for(j = 0;j <= 3;j++)    /*    0••3 cause 4 points in a tetrahedron    */
  573.                 {
  574.                     preplot4[j][0] = (**w_objs_hndl).bg_object[2]._3dPt_BG[j].x_point -offset.h;
  575.                     preplot4[j][1] = (**w_objs_hndl).bg_object[2]._3dPt_BG[j].y_point -offset.v;
  576.                     preplot4[j][2] = (**w_objs_hndl).bg_object[2]._3dPt_BG[j].z_point;
  577.                     preplot4[j][3] = (**w_objs_hndl).bg_object[2]._3dPt_BG[j].no_point;
  578.                 }
  579.                 /*    transform to relative VRP    */
  580.                 for(j = 0;j <= 3;j++)        /*    initialize xForm4    */
  581.                 {
  582.                     for(k = 0;k <= 3;k++)
  583.                     {
  584.                         xForm4[j][k] = 0.0;                
  585.                     }
  586.                 }
  587.                         /*    set VRP    */
  588.         
  589.                 VRPxform[0][3] = -1.0 * xVan;
  590.                 VRPxform[1][3] = -1.0 * yVan;
  591.  
  592.                 for(j = 0;j <= 3;j++)
  593.                 {
  594.                     for(k = 0;k <= 3;k++)
  595.                     {
  596.                         for(i = 0;i <= 3;i++)
  597.                         {
  598.                             xForm4[j][k] += VRPxform[k][i] * preplot4[j][i];                
  599.                         }
  600.                     }
  601.                 }                /* first create persMat    */
  602.                 for(j = 0;j <= 3;j++)
  603.                 {
  604.                     for(k = 0;k <= 3;k++)
  605.                     {
  606.                         for(m = 0;m <= 3;m++)
  607.                         {
  608.                             if(m == k)    pers4Mat[j][k][m] = 1;
  609.                             else        pers4Mat[j][k][m] = 0;
  610.                         }
  611.                     }
  612.                 }
  613.                 for(j = 0;j <= 3;j++)        /*    cause four vertices in the object    */
  614.                 {
  615.                     Wtemp4[j] = (xForm4[j][2]) / zScale;                /*    tenth try    */
  616.                 }
  617.                 for(m = 0;m <= 3;m++)
  618.                 {
  619.                     for(k = 0;k <= 2;k++)
  620.                     {
  621.                         newPers4Vect[m][k] = 0;
  622.                     }
  623.                     newPers4Vect[m][3] = 1;
  624.                 }
  625.                 for(m = 0;m <= 3;m++)            /*      *-------------- vertice point    */
  626.                 {                                /*    |  *----------- column        */
  627.                     for(k = 0;k <= 2;k++)        /*      |  |  *-------- vertice point */
  628.                     {                            /*      v  v  v                        */
  629.                         newPers4Vect[m][k] =   xForm4[m][k]/(Wtemp4[m]);
  630.                     }
  631.                 }
  632.                 /*    transform back from VRP    */
  633.  
  634.                 VRPxform[0][3] = xVan;
  635.                 VRPxform[1][3] = yVan;
  636.                 
  637.                 for(j = 0;j <= 3;j++)
  638.                 {
  639.                     for(k = 0;k <= 3;k++)
  640.                     {
  641.                         xForm4[j][k] = 0;                
  642.                     }
  643.                 }
  644.  
  645.                 for(j = 0;j <= 3;j++)
  646.                 {
  647.                     for(k = 0;k <= 3;k++)
  648.                     {
  649.                         for(i = 0;i <= 3;i++)
  650.                         {
  651.                             xForm4[j][k] += VRPxform[k][i] * newPers4Vect[j][i];                
  652.                         }
  653.                     }
  654.                 }
  655.                 for(j = 0;j <= 3;j++)
  656.                 {
  657.                     for(k = 0;k <= 3;k++)
  658.                     {
  659.                         newPers4Vect[j][k] = xForm4[j][k];
  660.                     }
  661.                 }                                                                                    
  662.                 MoveTo(newPers4Vect[0][0],newPers4Vect[0][1]);    /*    third tetrahedron    */
  663.                 LineTo(newPers4Vect[1][0],newPers4Vect[1][1]);
  664.                 thePoly = OpenPoly();
  665.                 LineTo(newPers4Vect[2][0],newPers4Vect[2][1]);
  666.                 LineTo(newPers4Vect[3][0],newPers4Vect[3][1]);
  667.                 LineTo(newPers4Vect[1][0],newPers4Vect[1][1]);
  668.                 ClosePoly();
  669.                 FillPoly( thePoly,&qd.gray);
  670.                                                                                                                         LineTo(newPers4Vect[1][0],newPers4Vect[1][1]);
  671.                 MoveTo(newPers4Vect[2][0],newPers4Vect[2][1]);
  672.                 LineTo(newPers4Vect[0][0],newPers4Vect[0][1]);
  673.                 LineTo(newPers4Vect[3][0],newPers4Vect[3][1]);
  674.             }
  675.             else    // if (!noShow)
  676.             {
  677.                 MoveTo((**w_objs_hndl).bg_object[2]._3dPt_BG[0].x_point -offset.h,        /*    third tetrahedron    */
  678.                         (**w_objs_hndl).bg_object[2]._3dPt_BG[0].y_point -offset.v);
  679.                 LineTo((**w_objs_hndl).bg_object[2]._3dPt_BG[1].x_point -offset.h,
  680.                         (**w_objs_hndl).bg_object[2]._3dPt_BG[1].y_point -offset.v);
  681.                 LineTo((**w_objs_hndl).bg_object[2]._3dPt_BG[2].x_point -offset.h,
  682.                         (**w_objs_hndl).bg_object[2]._3dPt_BG[2].y_point -offset.v);
  683.                 LineTo((**w_objs_hndl).bg_object[2]._3dPt_BG[0].x_point -offset.h,
  684.                         (**w_objs_hndl).bg_object[2]._3dPt_BG[0].y_point -offset.v);
  685.                 LineTo((**w_objs_hndl).bg_object[2]._3dPt_BG[3].x_point -offset.h,
  686.                         (**w_objs_hndl).bg_object[2]._3dPt_BG[3].y_point -offset.v);
  687.                 LineTo((**w_objs_hndl).bg_object[2]._3dPt_BG[1].x_point -offset.h,
  688.                         (**w_objs_hndl).bg_object[2]._3dPt_BG[1].y_point -offset.v);
  689.                 MoveTo((**w_objs_hndl).bg_object[2]._3dPt_BG[2].x_point -offset.h,
  690.                         (**w_objs_hndl).bg_object[2]._3dPt_BG[2].y_point -offset.v);
  691.                 LineTo((**w_objs_hndl).bg_object[2]._3dPt_BG[3].x_point -offset.h,
  692.                         (**w_objs_hndl).bg_object[2]._3dPt_BG[3].y_point -offset.v);
  693.             }
  694.         }
  695.         if(    (**w_objs_hndl).bg_object[3]._3dPt_BG[0].z_point < 0 &&
  696.             (**w_objs_hndl).bg_object[3]._3dPt_BG[1].z_point < 0 &&
  697.             (**w_objs_hndl).bg_object[3]._3dPt_BG[2].z_point < 0 &&
  698.             (**w_objs_hndl).bg_object[3]._3dPt_BG[3].z_point < 0 &&
  699.             (**w_objs_hndl).bg_object[3]._3dPt_BG[4].z_point < 0 &&
  700.             (**w_objs_hndl).bg_object[3]._3dPt_BG[5].z_point < 0 &&
  701.             (**w_objs_hndl).bg_object[3]._3dPt_BG[6].z_point < 0 &&
  702.             (**w_objs_hndl).bg_object[3]._3dPt_BG[7].z_point < 0)
  703.         {
  704.             if(doPers)            /*    first column    */
  705.             {
  706.                 for(j = 0;j <= 7;j++)    /*    0••7 cause 8 points in a cube or column    */
  707.                 {
  708.                     //960620
  709.                     preplot8[j][0] = (**w_objs_hndl).bg_object[3]._3dPt_BG[j].x_point -offset.h;
  710.                     preplot8[j][1] = (**w_objs_hndl).bg_object[3]._3dPt_BG[j].y_point -offset.v;
  711.                     preplot8[j][2] = (**w_objs_hndl).bg_object[3]._3dPt_BG[j].z_point;
  712.                     preplot8[j][3] = (**w_objs_hndl).bg_object[3]._3dPt_BG[j].no_point;
  713.                 }
  714.                 /*    transform to relative VRP    */
  715.                 for(j = 0;j <= 7;j++)
  716.                 {
  717.                     for(k = 0;k <= 3;k++)
  718.                     {
  719.                         xForm8[j][k] = 0.0;                
  720.                     }
  721.                 }
  722.                 
  723.                 VRPxform[0][3] = -1.0 * xVan;
  724.                 VRPxform[1][3] = -1.0 * yVan;
  725.                 
  726.                 for(j = 0;j <= 7;j++)
  727.                 {
  728.                     for(k = 0;k <= 3;k++)
  729.                     {
  730.                         for(i = 0;i <= 3;i++)
  731.                         {
  732.                             xForm8[j][k] += VRPxform[k][i] * preplot8[j][i];                
  733.                         }
  734.                     }
  735.                 }
  736.                 /* first create and initialize persMat    */
  737.                 for(j = 0;j <= 7;j++)                                                                    /*    Create the translation matrices    */
  738.                 {
  739.                     for(k = 0;k <= 3;k++)
  740.                     {
  741.                         for(m = 0;m <= 3;m++)
  742.                         {
  743.                             if(m == k)    pers8Mat[j][k][m] = 1;
  744.                             else        pers8Mat[j][k][m] = 0;
  745.                         }
  746.                     }
  747.                 }
  748.                 for(j = 0;j <= 7;j++)        /*    cause eight vertices in the object    */
  749.                 {
  750.                     Wtemp8[j] = (xForm8[j][2]) / zScale;                                                            /*    tenth try    */
  751.                 }
  752.                 for(m = 0;m <= 7;m++)
  753.                 {
  754.                     for(k = 0;k <= 2;k++)
  755.                     {
  756.                         newPers8Vect[m][k] = 0;
  757.                     }
  758.                     newPers8Vect[m][3] = 1;
  759.                 }
  760.                 for(m = 0;m <= 7;m++)    // which vertex
  761.                 {
  762.                                                 /*      *---------------- vertice point    */
  763.                                                 /*    |  *------------- row                */
  764.                     for(k = 0;k <= 2;k++)        /*      |  |          *-- vertice point    */
  765.                     {                            /*      v  v          v                            */
  766.                         newPers8Vect[m][k]    =  xForm8[m][k]/(Wtemp8[m]);
  767.                     }
  768.                 }
  769.                 /*    transform back from VRP    */
  770.  
  771.                 VRPxform[0][3] = xVan;
  772.                 VRPxform[1][3] = yVan;
  773.                 
  774.                 for(j = 0;j <= 7;j++)
  775.                 {
  776.                     for(k = 0;k <= 3;k++)
  777.                     {
  778.                         xForm8[j][k] = 0;                
  779.                     }
  780.                 }
  781.  
  782.                 for(j = 0;j <= 7;j++)
  783.                 {
  784.                     for(k = 0;k <= 3;k++)
  785.                     {
  786.                         for(i = 0;i <= 3;i++)
  787.                         {
  788.                             xForm8[j][k] += VRPxform[k][i] * newPers8Vect[j][i];                
  789.                         }
  790.                     }
  791.                 }
  792.                 for(j = 0;j <= 7;j++)
  793.                 {
  794.                     for(k = 0;k <= 3;k++)
  795.                     {
  796.                         newPers8Vect[j][k] = xForm8[j][k];
  797.                     }
  798.                 }
  799.                 MoveTo(newPers8Vect[0][0],newPers8Vect[0][1]);        /*    first column    */
  800.                 thePoly = OpenPoly();
  801.                 LineTo(newPers8Vect[1][0],newPers8Vect[1][1]);
  802.                 LineTo(newPers8Vect[2][0],newPers8Vect[2][1]);
  803.                 LineTo(newPers8Vect[3][0],newPers8Vect[3][1]);
  804.                 LineTo(newPers8Vect[0][0],newPers8Vect[0][1]);
  805.                 ClosePoly();
  806.                 FillPoly( thePoly,&qd.black);
  807.                 LineTo(newPers8Vect[4][0],newPers8Vect[4][1]);
  808.                 thePoly = OpenPoly();
  809.                 LineTo(newPers8Vect[5][0],newPers8Vect[5][1]);
  810.                 LineTo(newPers8Vect[6][0],newPers8Vect[6][1]);
  811.                 LineTo(newPers8Vect[7][0],newPers8Vect[7][1]);
  812.                 LineTo(newPers8Vect[4][0],newPers8Vect[4][1]);
  813.                 ClosePoly();
  814.                 FillPoly( thePoly,&qd.gray);
  815.                 MoveTo(newPers8Vect[1][0],newPers8Vect[1][1]);
  816.                 LineTo(newPers8Vect[5][0],newPers8Vect[5][1]);
  817.                 MoveTo(newPers8Vect[2][0],newPers8Vect[2][1]);
  818.                 LineTo(newPers8Vect[6][0],newPers8Vect[6][1]);
  819.                 MoveTo(newPers8Vect[3][0],newPers8Vect[3][1]);
  820.                 LineTo(newPers8Vect[7][0],newPers8Vect[7][1]);
  821.             }
  822.             else    // if (!noShow) /*if(!debugPers)*/
  823.             {
  824.                 MoveTo((**w_objs_hndl).bg_object[3]._3dPt_BG[0].x_point -offset.h,            /*    first column    */
  825.                         (**w_objs_hndl).bg_object[3]._3dPt_BG[0].y_point -offset.v);
  826.                 LineTo((**w_objs_hndl).bg_object[3]._3dPt_BG[1].x_point -offset.h,
  827.                         (**w_objs_hndl).bg_object[3]._3dPt_BG[1].y_point -offset.v);
  828.                 LineTo((**w_objs_hndl).bg_object[3]._3dPt_BG[2].x_point -offset.h,
  829.                         (**w_objs_hndl).bg_object[3]._3dPt_BG[2].y_point -offset.v);
  830.                 LineTo((**w_objs_hndl).bg_object[3]._3dPt_BG[3].x_point -offset.h,
  831.                         (**w_objs_hndl).bg_object[3]._3dPt_BG[3].y_point -offset.v);
  832.                 LineTo((**w_objs_hndl).bg_object[3]._3dPt_BG[0].x_point -offset.h,
  833.                         (**w_objs_hndl).bg_object[3]._3dPt_BG[0].y_point -offset.v);
  834.                 LineTo((**w_objs_hndl).bg_object[3]._3dPt_BG[4].x_point -offset.h,
  835.                         (**w_objs_hndl).bg_object[3]._3dPt_BG[4].y_point -offset.v);
  836.                 LineTo((**w_objs_hndl).bg_object[3]._3dPt_BG[5].x_point -offset.h,
  837.                         (**w_objs_hndl).bg_object[3]._3dPt_BG[5].y_point -offset.v);
  838.                 LineTo((**w_objs_hndl).bg_object[3]._3dPt_BG[6].x_point -offset.h,
  839.                         (**w_objs_hndl).bg_object[3]._3dPt_BG[6].y_point -offset.v);
  840.                 LineTo((**w_objs_hndl).bg_object[3]._3dPt_BG[7].x_point -offset.h,
  841.                         (**w_objs_hndl).bg_object[3]._3dPt_BG[7].y_point -offset.v);
  842.                 LineTo((**w_objs_hndl).bg_object[3]._3dPt_BG[4].x_point -offset.h,
  843.                         (**w_objs_hndl).bg_object[3]._3dPt_BG[4].y_point -offset.v);
  844.                 MoveTo((**w_objs_hndl).bg_object[3]._3dPt_BG[1].x_point -offset.h,
  845.                         (**w_objs_hndl).bg_object[3]._3dPt_BG[1].y_point -offset.v);
  846.                 LineTo((**w_objs_hndl).bg_object[3]._3dPt_BG[5].x_point -offset.h,
  847.                         (**w_objs_hndl).bg_object[3]._3dPt_BG[5].y_point -offset.v);
  848.                 MoveTo((**w_objs_hndl).bg_object[3]._3dPt_BG[2].x_point -offset.h,
  849.                         (**w_objs_hndl).bg_object[3]._3dPt_BG[2].y_point -offset.v);
  850.                 LineTo((**w_objs_hndl).bg_object[3]._3dPt_BG[6].x_point -offset.h,
  851.                         (**w_objs_hndl).bg_object[3]._3dPt_BG[6].y_point -offset.v);
  852.                 MoveTo((**w_objs_hndl).bg_object[3]._3dPt_BG[3].x_point -offset.h,
  853.                         (**w_objs_hndl).bg_object[3]._3dPt_BG[3].y_point -offset.v);
  854.                 LineTo((**w_objs_hndl).bg_object[3]._3dPt_BG[7].x_point -offset.h,
  855.                         (**w_objs_hndl).bg_object[3]._3dPt_BG[7].y_point -offset.v);
  856.             }
  857.         }
  858.         if(    (**w_objs_hndl).bg_object[4]._3dPt_BG[0].z_point < 0 &&
  859.             (**w_objs_hndl).bg_object[4]._3dPt_BG[1].z_point < 0 &&
  860.             (**w_objs_hndl).bg_object[4]._3dPt_BG[2].z_point < 0 &&
  861.             (**w_objs_hndl).bg_object[4]._3dPt_BG[3].z_point < 0 &&
  862.             (**w_objs_hndl).bg_object[4]._3dPt_BG[4].z_point < 0 &&
  863.             (**w_objs_hndl).bg_object[4]._3dPt_BG[5].z_point < 0 &&
  864.             (**w_objs_hndl).bg_object[4]._3dPt_BG[6].z_point < 0 &&
  865.             (**w_objs_hndl).bg_object[4]._3dPt_BG[7].z_point < 0)
  866.         {
  867.             if(doPers)            // && (**w_objs_hndl).isPrey)        /*    work area    */
  868.             {
  869.                 for(j = 0;j <= 7;j++)    /*    j is point in the object    */
  870.                 {                        /*    0••7 cause 8 points in a cube or column    */                    /*    Use convenient local variable    */
  871.                     preplot8[j][0] = (**w_objs_hndl).bg_object[4]._3dPt_BG[j].x_point -offset.h;        /*                                    */
  872.                     preplot8[j][1] = (**w_objs_hndl).bg_object[4]._3dPt_BG[j].y_point -offset.v;        /*                                    */
  873.                     preplot8[j][2] = (**w_objs_hndl).bg_object[4]._3dPt_BG[j].z_point;                    /*                                    */
  874.                     preplot8[j][3] = (**w_objs_hndl).bg_object[4]._3dPt_BG[j].no_point;                    /*                                    */
  875.                 }
  876.                 /*    transform to relative VRP    */
  877.                 for(j = 0;j <= 7;j++)
  878.                 {
  879.                     for(k = 0;k <= 3;k++)
  880.                     {
  881.                         xForm8[j][k] = 0.0;                
  882.                     }
  883.                 }
  884.                 
  885.                 VRPxform[0][3] = -1.0 * xVan;
  886.                 VRPxform[1][3] = -1.0 * yVan;
  887.                 
  888.                 for(j = 0;j <= 7;j++)
  889.                 {
  890.                     for(k = 0;k <= 3;k++)
  891.                     {
  892.                         for(i = 0;i <= 3;i++)
  893.                         {
  894.                             xForm8[j][k] += VRPxform[k][i] * preplot8[j][i];                
  895.                         }
  896.                     }
  897.                 }
  898.                 /* first create and initialize persMat    */
  899.                 for(j = 0;j <= 7;j++)                                                                    /*    Create the translation matrices    */
  900.                 {
  901.                     for(k = 0;k <= 3;k++)
  902.                     {
  903.                         for(m = 0;m <= 3;m++)
  904.                         {
  905.                             if(m == k)    pers8Mat[j][k][m] = 1;
  906.                             else        pers8Mat[j][k][m] = 0;
  907.                         }
  908.                     }
  909.                 }
  910.                 for(j = 0;j <= 7;j++)        /*    cause eight vertices in the object    */
  911.                 {
  912.                     Wtemp8[j] = (xForm8[j][2]) / zScale;                                                            /*    tenth try    */
  913.                 }
  914.                 for(m = 0;m <= 7;m++)
  915.                 {
  916.                     for(k = 0;k <= 2;k++)
  917.                     {
  918.                         newPers8Vect[m][k] = 0;
  919.                     }
  920.                     newPers8Vect[m][3] = 1;
  921.                 }
  922.                 for(m = 0;m <= 7;m++)    // which vertex
  923.                 {
  924.                                                 /*       *---------------- vertice point    */
  925.                                                 /*     |  *------------- row            */
  926.                     for(k = 0;k <= 2;k++)        /*       |  |          *--- vertice point    */
  927.                     {                            /*       v  v          v                            */
  928.                         newPers8Vect[m][k]    =  xForm8[m][k]/(Wtemp8[m]);
  929.                     }
  930.                 }        
  931.                 /*    transform back from VRP    */
  932.  
  933.                 VRPxform[0][3] = xVan;
  934.                 VRPxform[1][3] = yVan;
  935.                 
  936.                 for(j = 0;j <= 7;j++)
  937.                 {
  938.                     for(k = 0;k <= 3;k++)
  939.                     {
  940.                         xForm8[j][k] = 0;                
  941.                     }
  942.                 }
  943.  
  944.                 for(j = 0;j <= 7;j++)
  945.                 {
  946.                     for(k = 0;k <= 3;k++)
  947.                     {
  948.                         for(i = 0;i <= 3;i++)
  949.                         {
  950.                             xForm8[j][k] += VRPxform[k][i] * newPers8Vect[j][i];                
  951.                         }
  952.                     }
  953.                 }
  954.                 for(j = 0;j <= 7;j++)
  955.                 {
  956.                     for(k = 0;k <= 3;k++)
  957.                     {
  958.                         newPers8Vect[j][k] = xForm8[j][k];
  959.                     }
  960.                 }
  961.                 //DebugStr("\pThis is a fucking test");
  962.                 
  963.                 MoveTo(newPers8Vect[0][0],newPers8Vect[0][1]);        /*    second column    */
  964.                 thePoly = OpenPoly();
  965.                 LineTo(newPers8Vect[1][0],newPers8Vect[1][1]);
  966.                 LineTo(newPers8Vect[2][0],newPers8Vect[2][1]);
  967.                 LineTo(newPers8Vect[3][0],newPers8Vect[3][1]);
  968.                 LineTo(newPers8Vect[0][0],newPers8Vect[0][1]);
  969.                 ClosePoly();
  970.                 FillPoly( thePoly,&qd.gray);
  971.                 LineTo(newPers8Vect[4][0],newPers8Vect[4][1]);
  972.                 thePoly = OpenPoly();
  973.                 LineTo(newPers8Vect[5][0],newPers8Vect[5][1]);
  974.                 LineTo(newPers8Vect[6][0],newPers8Vect[6][1]);
  975.                 LineTo(newPers8Vect[7][0],newPers8Vect[7][1]);
  976.                 LineTo(newPers8Vect[4][0],newPers8Vect[4][1]);
  977.                 ClosePoly();
  978.                 FillPoly( thePoly,&qd.gray);
  979.                 MoveTo(newPers8Vect[1][0],newPers8Vect[1][1]);
  980.                 LineTo(newPers8Vect[5][0],newPers8Vect[5][1]);
  981.                 MoveTo(newPers8Vect[2][0],newPers8Vect[2][1]);
  982.                 LineTo(newPers8Vect[6][0],newPers8Vect[6][1]);
  983.                 MoveTo(newPers8Vect[3][0],newPers8Vect[3][1]);
  984.                 LineTo(newPers8Vect[7][0],newPers8Vect[7][1]);                
  985.             }
  986.             //else if (!noShow)
  987.             else    // if (noShow)
  988.             
  989.             {
  990.                 //DebugStr("\pThis is a test");
  991.                 
  992.                 MoveTo((**w_objs_hndl).bg_object[4]._3dPt_BG[0].x_point -offset.h,            /*    second column    */
  993.                         (**w_objs_hndl).bg_object[4]._3dPt_BG[0].y_point -offset.v);
  994.                 LineTo((**w_objs_hndl).bg_object[4]._3dPt_BG[1].x_point -offset.h,
  995.                         (**w_objs_hndl).bg_object[4]._3dPt_BG[1].y_point -offset.v);
  996.                 LineTo((**w_objs_hndl).bg_object[4]._3dPt_BG[2].x_point -offset.h,
  997.                         (**w_objs_hndl).bg_object[4]._3dPt_BG[2].y_point -offset.v);
  998.                 LineTo((**w_objs_hndl).bg_object[4]._3dPt_BG[3].x_point -offset.h,
  999.                         (**w_objs_hndl).bg_object[4]._3dPt_BG[3].y_point -offset.v);
  1000.                 LineTo((**w_objs_hndl).bg_object[4]._3dPt_BG[0].x_point -offset.h,
  1001.                         (**w_objs_hndl).bg_object[4]._3dPt_BG[0].y_point -offset.v);
  1002.                 LineTo((**w_objs_hndl).bg_object[4]._3dPt_BG[4].x_point -offset.h,
  1003.                         (**w_objs_hndl).bg_object[4]._3dPt_BG[4].y_point -offset.v);
  1004.                 LineTo((**w_objs_hndl).bg_object[4]._3dPt_BG[5].x_point -offset.h,
  1005.                         (**w_objs_hndl).bg_object[4]._3dPt_BG[5].y_point -offset.v);
  1006.                 LineTo((**w_objs_hndl).bg_object[4]._3dPt_BG[6].x_point -offset.h,
  1007.                         (**w_objs_hndl).bg_object[4]._3dPt_BG[6].y_point -offset.v);
  1008.                 LineTo((**w_objs_hndl).bg_object[4]._3dPt_BG[7].x_point -offset.h,
  1009.                         (**w_objs_hndl).bg_object[4]._3dPt_BG[7].y_point -offset.v);
  1010.                 LineTo((**w_objs_hndl).bg_object[4]._3dPt_BG[4].x_point -offset.h,
  1011.                         (**w_objs_hndl).bg_object[4]._3dPt_BG[4].y_point -offset.v);
  1012.                 MoveTo((**w_objs_hndl).bg_object[4]._3dPt_BG[1].x_point -offset.h,
  1013.                         (**w_objs_hndl).bg_object[4]._3dPt_BG[1].y_point -offset.v);
  1014.                 LineTo((**w_objs_hndl).bg_object[4]._3dPt_BG[5].x_point -offset.h,
  1015.                         (**w_objs_hndl).bg_object[4]._3dPt_BG[5].y_point -offset.v);
  1016.                 MoveTo((**w_objs_hndl).bg_object[4]._3dPt_BG[2].x_point -offset.h,
  1017.                         (**w_objs_hndl).bg_object[4]._3dPt_BG[2].y_point -offset.v);
  1018.                 LineTo((**w_objs_hndl).bg_object[4]._3dPt_BG[6].x_point -offset.h,
  1019.                         (**w_objs_hndl).bg_object[4]._3dPt_BG[6].y_point -offset.v);
  1020.                 MoveTo((**w_objs_hndl).bg_object[4]._3dPt_BG[3].x_point -offset.h,
  1021.                         (**w_objs_hndl).bg_object[4]._3dPt_BG[3].y_point -offset.v);
  1022.                 LineTo((**w_objs_hndl).bg_object[4]._3dPt_BG[7].x_point -offset.h,
  1023.                         (**w_objs_hndl).bg_object[4]._3dPt_BG[7].y_point -offset.v);
  1024.             }
  1025.         }
  1026.         if(    (**w_objs_hndl).bg_object[5]._3dPt_BG[0].z_point < 0 &&
  1027.             (**w_objs_hndl).bg_object[5]._3dPt_BG[1].z_point < 0 &&
  1028.             (**w_objs_hndl).bg_object[5]._3dPt_BG[2].z_point < 0 &&
  1029.             (**w_objs_hndl).bg_object[5]._3dPt_BG[3].z_point < 0 &&
  1030.             (**w_objs_hndl).bg_object[5]._3dPt_BG[4].z_point < 0 &&
  1031.             (**w_objs_hndl).bg_object[5]._3dPt_BG[5].z_point < 0 &&
  1032.             (**w_objs_hndl).bg_object[5]._3dPt_BG[6].z_point < 0 &&
  1033.             (**w_objs_hndl).bg_object[5]._3dPt_BG[7].z_point < 0)
  1034.         {
  1035.             if(doPers && !debugPers)
  1036.             {
  1037.                 for(j = 0;j <= 7;j++)    /*    j is point in the object    */
  1038.                 {                        /*    0••7 cause 8 points in a cube or column    */
  1039.                     preplot8[j][0] = (**w_objs_hndl).bg_object[5]._3dPt_BG[j].x_point -offset.h;
  1040.                     preplot8[j][1] = (**w_objs_hndl).bg_object[5]._3dPt_BG[j].y_point -offset.v;
  1041.                     preplot8[j][2] = (**w_objs_hndl).bg_object[5]._3dPt_BG[j].z_point;
  1042.                     preplot8[j][3] = (**w_objs_hndl).bg_object[5]._3dPt_BG[j].no_point;
  1043.                 }
  1044.                 /*    transform to relative VRP    */
  1045.                 for(j = 0;j <= 7;j++)
  1046.                 {
  1047.                     for(k = 0;k <= 3;k++)
  1048.                     {
  1049.                         xForm8[j][k] = 0.0;                
  1050.                     }
  1051.                 }
  1052.                 
  1053.                 VRPxform[0][3] = -1.0 * xVan;
  1054.                 VRPxform[1][3] = -1.0 * yVan;
  1055.                 
  1056.                 for(j = 0;j <= 7;j++)
  1057.                 {
  1058.                     for(k = 0;k <= 3;k++)
  1059.                     {
  1060.                         for(i = 0;i <= 3;i++)
  1061.                         {
  1062.                             xForm8[j][k] += VRPxform[k][i] * preplot8[j][i];                
  1063.                         }
  1064.                     }
  1065.                 }
  1066.                 /* first create and initialize persMat    */
  1067.                 for(j = 0;j <= 7;j++)                                                                    /*    Create the translation matrices    */
  1068.                 {
  1069.                     for(k = 0;k <= 3;k++)
  1070.                     {
  1071.                         for(m = 0;m <= 3;m++)
  1072.                         {
  1073.                             if(m == k)    pers8Mat[j][k][m] = 1;
  1074.                             else        pers8Mat[j][k][m] = 0;
  1075.                         }
  1076.                     }
  1077.                 }
  1078.                 for(j = 0;j <= 7;j++)        /*    cause eight vertices in the object    */
  1079.                 {
  1080.                     Wtemp8[j] = (xForm8[j][2]) / zScale;                                                            /*    tenth try    */
  1081.                 }
  1082.                 for(m = 0;m <= 7;m++)
  1083.                 {
  1084.                     for(k = 0;k <= 2;k++)
  1085.                     {
  1086.                         newPers8Vect[m][k] = 0;
  1087.                     }
  1088.                     newPers8Vect[m][3] = 1;
  1089.                 }
  1090.                 for(m = 0;m <= 7;m++)    // which vertex
  1091.                 {
  1092.                                                 /*      *---------------- vertice point    */
  1093.                                                 /*    |  *------------- row                */
  1094.                     for(k = 0;k <= 2;k++)        /*      |  |          *-- vertice point    */
  1095.                     {                            /*      v  v          v                            */
  1096.                         newPers8Vect[m][k]    =  xForm8[m][k]/(Wtemp8[m]);
  1097.                     }
  1098.                 }
  1099.                 /*    transform back from VRP    */
  1100.  
  1101.                 VRPxform[0][3] = xVan;
  1102.                 VRPxform[1][3] = yVan;
  1103.                 
  1104.                 for(j = 0;j <= 7;j++)
  1105.                 {
  1106.                     for(k = 0;k <= 3;k++)
  1107.                     {
  1108.                         xForm8[j][k] = 0;                
  1109.                     }
  1110.                 }
  1111.  
  1112.                 for(j = 0;j <= 7;j++)
  1113.                 {
  1114.                     for(k = 0;k <= 3;k++)
  1115.                     {
  1116.                         for(i = 0;i <= 3;i++)
  1117.                         {
  1118.                             xForm8[j][k] += VRPxform[k][i] * newPers8Vect[j][i];                
  1119.                         }
  1120.                     }
  1121.                 }
  1122.                 for(j = 0;j <= 7;j++)
  1123.                 {
  1124.                     for(k = 0;k <= 3;k++)
  1125.                     {
  1126.                         newPers8Vect[j][k] = xForm8[j][k];
  1127.                     }
  1128.                 }
  1129.                 MoveTo(newPers8Vect[0][0],newPers8Vect[0][1]);        /*    third column    */
  1130.                 thePoly = OpenPoly();
  1131.                 LineTo(newPers8Vect[1][0],newPers8Vect[1][1]);
  1132.                 LineTo(newPers8Vect[2][0],newPers8Vect[2][1]);
  1133.                 LineTo(newPers8Vect[3][0],newPers8Vect[3][1]);
  1134.                 LineTo(newPers8Vect[0][0],newPers8Vect[0][1]);
  1135.                 ClosePoly();
  1136.                 FillPoly( thePoly,&qd.gray);
  1137.                 LineTo(newPers8Vect[4][0],newPers8Vect[4][1]);
  1138.                 thePoly = OpenPoly();
  1139.                 LineTo(newPers8Vect[5][0],newPers8Vect[5][1]);
  1140.                 LineTo(newPers8Vect[6][0],newPers8Vect[6][1]);
  1141.                 LineTo(newPers8Vect[7][0],newPers8Vect[7][1]);
  1142.                 LineTo(newPers8Vect[4][0],newPers8Vect[4][1]);
  1143.                 ClosePoly();
  1144.                 FillPoly( thePoly,&qd.black);
  1145.                 MoveTo(newPers8Vect[1][0],newPers8Vect[1][1]);
  1146.                 LineTo(newPers8Vect[5][0],newPers8Vect[5][1]);
  1147.                 MoveTo(newPers8Vect[2][0],newPers8Vect[2][1]);
  1148.                 LineTo(newPers8Vect[6][0],newPers8Vect[6][1]);
  1149.                 MoveTo(newPers8Vect[3][0],newPers8Vect[3][1]);
  1150.                 LineTo(newPers8Vect[7][0],newPers8Vect[7][1]);
  1151.             }
  1152.             else //    if (!noShow)        //if(!debugPers)
  1153.             {
  1154.                 MoveTo((**w_objs_hndl).bg_object[5]._3dPt_BG[0].x_point -offset.h,            /*    third column    */
  1155.                         (**w_objs_hndl).bg_object[5]._3dPt_BG[0].y_point -offset.v);
  1156.                 LineTo((**w_objs_hndl).bg_object[5]._3dPt_BG[1].x_point -offset.h,
  1157.                         (**w_objs_hndl).bg_object[5]._3dPt_BG[1].y_point -offset.v);
  1158.                 LineTo((**w_objs_hndl).bg_object[5]._3dPt_BG[2].x_point -offset.h,
  1159.                         (**w_objs_hndl).bg_object[5]._3dPt_BG[2].y_point -offset.v);
  1160.                 LineTo((**w_objs_hndl).bg_object[5]._3dPt_BG[3].x_point -offset.h,
  1161.                         (**w_objs_hndl).bg_object[5]._3dPt_BG[3].y_point -offset.v);
  1162.                 LineTo((**w_objs_hndl).bg_object[5]._3dPt_BG[0].x_point -offset.h,
  1163.                         (**w_objs_hndl).bg_object[5]._3dPt_BG[0].y_point -offset.v);
  1164.                 LineTo((**w_objs_hndl).bg_object[5]._3dPt_BG[4].x_point -offset.h,
  1165.                         (**w_objs_hndl).bg_object[5]._3dPt_BG[4].y_point -offset.v);
  1166.                 LineTo((**w_objs_hndl).bg_object[5]._3dPt_BG[5].x_point -offset.h,
  1167.                         (**w_objs_hndl).bg_object[5]._3dPt_BG[5].y_point -offset.v);
  1168.                 LineTo((**w_objs_hndl).bg_object[5]._3dPt_BG[6].x_point -offset.h,
  1169.                         (**w_objs_hndl).bg_object[5]._3dPt_BG[6].y_point -offset.v);
  1170.                 LineTo((**w_objs_hndl).bg_object[5]._3dPt_BG[7].x_point -offset.h,
  1171.                         (**w_objs_hndl).bg_object[5]._3dPt_BG[7].y_point -offset.v);
  1172.                 LineTo((**w_objs_hndl).bg_object[5]._3dPt_BG[4].x_point -offset.h,
  1173.                         (**w_objs_hndl).bg_object[5]._3dPt_BG[4].y_point -offset.v);
  1174.                 MoveTo((**w_objs_hndl).bg_object[5]._3dPt_BG[1].x_point -offset.h,
  1175.                         (**w_objs_hndl).bg_object[5]._3dPt_BG[1].y_point -offset.v);
  1176.                 LineTo((**w_objs_hndl).bg_object[5]._3dPt_BG[5].x_point -offset.h,
  1177.                         (**w_objs_hndl).bg_object[5]._3dPt_BG[5].y_point -offset.v);
  1178.                 MoveTo((**w_objs_hndl).bg_object[5]._3dPt_BG[2].x_point -offset.h,
  1179.                         (**w_objs_hndl).bg_object[5]._3dPt_BG[2].y_point -offset.v);
  1180.                 LineTo((**w_objs_hndl).bg_object[5]._3dPt_BG[6].x_point -offset.h,
  1181.                         (**w_objs_hndl).bg_object[5]._3dPt_BG[6].y_point -offset.v);
  1182.                 MoveTo((**w_objs_hndl).bg_object[5]._3dPt_BG[3].x_point -offset.h,
  1183.                         (**w_objs_hndl).bg_object[5]._3dPt_BG[3].y_point -offset.v);
  1184.                 LineTo((**w_objs_hndl).bg_object[5]._3dPt_BG[7].x_point -offset.h,
  1185.                         (**w_objs_hndl).bg_object[5]._3dPt_BG[7].y_point -offset.v);
  1186.             }
  1187.         }
  1188.         if(    (**w_objs_hndl).bg_object[6]._3dPt_BG[0].z_point < 0 &&
  1189.             (**w_objs_hndl).bg_object[6]._3dPt_BG[1].z_point < 0 &&
  1190.             (**w_objs_hndl).bg_object[6]._3dPt_BG[2].z_point < 0 &&
  1191.             (**w_objs_hndl).bg_object[6]._3dPt_BG[3].z_point < 0 &&
  1192.             (**w_objs_hndl).bg_object[6]._3dPt_BG[4].z_point < 0 &&
  1193.             (**w_objs_hndl).bg_object[6]._3dPt_BG[5].z_point < 0 &&
  1194.             (**w_objs_hndl).bg_object[6]._3dPt_BG[6].z_point < 0 &&
  1195.             (**w_objs_hndl).bg_object[6]._3dPt_BG[7].z_point < 0)
  1196.         {
  1197.             if(doPers)
  1198.             {
  1199.                 for(j = 0;j <= 7;j++)    /*    j is point in the object    */
  1200.                 {                        /*    0••7 cause 8 points in a cube or column    */
  1201.                     preplot8[j][0] = (**w_objs_hndl).bg_object[6]._3dPt_BG[j].x_point -offset.h;
  1202.                     preplot8[j][1] = (**w_objs_hndl).bg_object[6]._3dPt_BG[j].y_point -offset.v;
  1203.                     preplot8[j][2] = (**w_objs_hndl).bg_object[6]._3dPt_BG[j].z_point;
  1204.                     preplot8[j][3] = (**w_objs_hndl).bg_object[6]._3dPt_BG[j].no_point;
  1205.                 }
  1206.                 /*    transform to relative VRP    */
  1207.                 for(j = 0;j <= 7;j++)
  1208.                 {
  1209.                     for(k = 0;k <= 3;k++)
  1210.                     {
  1211.                         xForm8[j][k] = 0.0;                
  1212.                     }
  1213.                 }
  1214.                 
  1215.                 VRPxform[0][3] = -1.0 * xVan;
  1216.                 VRPxform[1][3] = -1.0 * yVan;
  1217.                 
  1218.                 for(j = 0;j <= 7;j++)
  1219.                 {
  1220.                     for(k = 0;k <= 3;k++)
  1221.                     {
  1222.                         for(i = 0;i <= 3;i++)
  1223.                         {
  1224.                             xForm8[j][k] += VRPxform[k][i] * preplot8[j][i];                
  1225.                         }
  1226.                     }
  1227.                 }
  1228.                 /* first create and initialize persMat    */
  1229.                 for(j = 0;j <= 7;j++)                                                                    /*    Create the translation matrices    */
  1230.                 {
  1231.                     for(k = 0;k <= 3;k++)
  1232.                     {
  1233.                         for(m = 0;m <= 3;m++)
  1234.                         {
  1235.                             if(m == k)    pers8Mat[j][k][m] = 1;
  1236.                             else        pers8Mat[j][k][m] = 0;
  1237.                         }
  1238.                     }
  1239.                 }
  1240.                 for(j = 0;j <= 7;j++)        /*    cause eight vertices in the object    */
  1241.                 {
  1242.                     Wtemp8[j] = (xForm8[j][2]) / zScale;                                                            /*    tenth try    */
  1243.                 }
  1244.                 for(m = 0;m <= 7;m++)
  1245.                 {
  1246.                     for(k = 0;k <= 2;k++)
  1247.                     {
  1248.                         newPers8Vect[m][k] = 0;
  1249.                     }
  1250.                     newPers8Vect[m][3] = 1;
  1251.                 }
  1252.                 for(m = 0;m <= 7;m++)    // which vertex
  1253.                 {
  1254.                                                 /*      *---------------- vertice point    */
  1255.                                                 /*    |  *------------- row                */
  1256.                     for(k = 0;k <= 2;k++)        /*      |  |          *-- vertice point    */
  1257.                     {                            /*      v  v          v                            */
  1258.                         newPers8Vect[m][k]    =  xForm8[m][k]/(Wtemp8[m]);
  1259.                     }
  1260.                 }
  1261.                 /*    transform back from VRP    */
  1262.  
  1263.                 VRPxform[0][3] = xVan;
  1264.                 VRPxform[1][3] = yVan;
  1265.                 
  1266.                 for(j = 0;j <= 7;j++)
  1267.                 {
  1268.                     for(k = 0;k <= 3;k++)
  1269.                     {
  1270.                         xForm8[j][k] = 0;                
  1271.                     }
  1272.                 }
  1273.  
  1274.                 for(j = 0;j <= 7;j++)
  1275.                 {
  1276.                     for(k = 0;k <= 3;k++)
  1277.                     {
  1278.                         for(i = 0;i <= 3;i++)
  1279.                         {
  1280.                             xForm8[j][k] += VRPxform[k][i] * newPers8Vect[j][i];                
  1281.                         }
  1282.                     }
  1283.                 }
  1284.                 for(j = 0;j <= 7;j++)
  1285.                 {
  1286.                     for(k = 0;k <= 3;k++)
  1287.                     {
  1288.                         newPers8Vect[j][k] = xForm8[j][k];
  1289.                     }
  1290.                 }                                                /*               *-------- column                    */                                                
  1291.                 MoveTo(newPers8Vect[0][0],newPers8Vect[0][1]);        /*    first cube    */
  1292.                 thePoly = OpenPoly();
  1293.                 LineTo(newPers8Vect[1][0],newPers8Vect[1][1]);
  1294.                 LineTo(newPers8Vect[2][0],newPers8Vect[2][1]);
  1295.                 LineTo(newPers8Vect[3][0],newPers8Vect[3][1]);
  1296.                 LineTo(newPers8Vect[0][0],newPers8Vect[0][1]);
  1297.                 ClosePoly();
  1298.                 FillPoly( thePoly,&qd.gray);
  1299.                 LineTo(newPers8Vect[4][0],newPers8Vect[4][1]);
  1300.                 thePoly = OpenPoly();
  1301.                 LineTo(newPers8Vect[5][0],newPers8Vect[5][1]);
  1302.                 LineTo(newPers8Vect[6][0],newPers8Vect[6][1]);
  1303.                 LineTo(newPers8Vect[7][0],newPers8Vect[7][1]);
  1304.                 LineTo(newPers8Vect[4][0],newPers8Vect[4][1]);
  1305.                 ClosePoly();
  1306.                 FillPoly( thePoly,&qd.black);
  1307.                 MoveTo(newPers8Vect[1][0],newPers8Vect[1][1]);
  1308.                 LineTo(newPers8Vect[5][0],newPers8Vect[5][1]);
  1309.                 MoveTo(newPers8Vect[2][0],newPers8Vect[2][1]);
  1310.                 LineTo(newPers8Vect[6][0],newPers8Vect[6][1]);
  1311.                 MoveTo(newPers8Vect[3][0],newPers8Vect[3][1]);
  1312.                 LineTo(newPers8Vect[7][0],newPers8Vect[7][1]);                
  1313.             }
  1314.             else    // if (!noShow)        // if(!debugPers)
  1315.             {
  1316.                 MoveTo((**w_objs_hndl).bg_object[6]._3dPt_BG[0].x_point -offset.h,                /*    first cube    */
  1317.                         (**w_objs_hndl).bg_object[6]._3dPt_BG[0].y_point -offset.v);
  1318.                 LineTo((**w_objs_hndl).bg_object[6]._3dPt_BG[1].x_point -offset.h,
  1319.                         (**w_objs_hndl).bg_object[6]._3dPt_BG[1].y_point -offset.v);
  1320.                 LineTo((**w_objs_hndl).bg_object[6]._3dPt_BG[2].x_point -offset.h,
  1321.                         (**w_objs_hndl).bg_object[6]._3dPt_BG[2].y_point -offset.v);
  1322.                 LineTo((**w_objs_hndl).bg_object[6]._3dPt_BG[3].x_point -offset.h,
  1323.                         (**w_objs_hndl).bg_object[6]._3dPt_BG[3].y_point -offset.v);
  1324.                 LineTo((**w_objs_hndl).bg_object[6]._3dPt_BG[0].x_point -offset.h,
  1325.                         (**w_objs_hndl).bg_object[6]._3dPt_BG[0].y_point -offset.v);
  1326.                 LineTo((**w_objs_hndl).bg_object[6]._3dPt_BG[4].x_point -offset.h,
  1327.                         (**w_objs_hndl).bg_object[6]._3dPt_BG[4].y_point -offset.v);
  1328.                 LineTo((**w_objs_hndl).bg_object[6]._3dPt_BG[5].x_point -offset.h,
  1329.                         (**w_objs_hndl).bg_object[6]._3dPt_BG[5].y_point -offset.v);
  1330.                 LineTo((**w_objs_hndl).bg_object[6]._3dPt_BG[6].x_point -offset.h,
  1331.                         (**w_objs_hndl).bg_object[6]._3dPt_BG[6].y_point -offset.v);
  1332.                 LineTo((**w_objs_hndl).bg_object[6]._3dPt_BG[7].x_point -offset.h,
  1333.                         (**w_objs_hndl).bg_object[6]._3dPt_BG[7].y_point -offset.v);
  1334.                 LineTo((**w_objs_hndl).bg_object[6]._3dPt_BG[4].x_point -offset.h,
  1335.                         (**w_objs_hndl).bg_object[6]._3dPt_BG[4].y_point -offset.v);
  1336.                 MoveTo((**w_objs_hndl).bg_object[6]._3dPt_BG[1].x_point -offset.h,
  1337.                         (**w_objs_hndl).bg_object[6]._3dPt_BG[1].y_point -offset.v);
  1338.                 LineTo((**w_objs_hndl).bg_object[6]._3dPt_BG[5].x_point -offset.h,
  1339.                         (**w_objs_hndl).bg_object[6]._3dPt_BG[5].y_point -offset.v);
  1340.                 MoveTo((**w_objs_hndl).bg_object[6]._3dPt_BG[2].x_point -offset.h,
  1341.                         (**w_objs_hndl).bg_object[6]._3dPt_BG[2].y_point -offset.v);
  1342.                 LineTo((**w_objs_hndl).bg_object[6]._3dPt_BG[6].x_point -offset.h,
  1343.                         (**w_objs_hndl).bg_object[6]._3dPt_BG[6].y_point -offset.v);
  1344.                 MoveTo((**w_objs_hndl).bg_object[6]._3dPt_BG[3].x_point -offset.h,
  1345.                         (**w_objs_hndl).bg_object[6]._3dPt_BG[3].y_point -offset.v);
  1346.                 LineTo((**w_objs_hndl).bg_object[6]._3dPt_BG[7].x_point -offset.h,
  1347.                         (**w_objs_hndl).bg_object[6]._3dPt_BG[7].y_point -offset.v);
  1348.             }
  1349.         }
  1350.         if(    (**w_objs_hndl).bg_object[7]._3dPt_BG[0].z_point < 0 &&
  1351.             (**w_objs_hndl).bg_object[7]._3dPt_BG[1].z_point < 0 &&
  1352.             (**w_objs_hndl).bg_object[7]._3dPt_BG[2].z_point < 0 &&
  1353.             (**w_objs_hndl).bg_object[7]._3dPt_BG[3].z_point < 0 &&
  1354.             (**w_objs_hndl).bg_object[7]._3dPt_BG[4].z_point < 0 &&
  1355.             (**w_objs_hndl).bg_object[7]._3dPt_BG[5].z_point < 0 &&
  1356.             (**w_objs_hndl).bg_object[7]._3dPt_BG[6].z_point < 0 &&
  1357.             (**w_objs_hndl).bg_object[7]._3dPt_BG[7].z_point < 0)
  1358.         {
  1359.             if(doPers && !debugPers)
  1360.             {
  1361.                 for(j = 0;j <= 7;j++)    /*    j is point in the object    */
  1362.                 {                        /*    0••7 cause 8 points in a cube or column    */
  1363.                     preplot8[j][0] = (**w_objs_hndl).bg_object[7]._3dPt_BG[j].x_point -offset.h;
  1364.                     preplot8[j][1] = (**w_objs_hndl).bg_object[7]._3dPt_BG[j].y_point -offset.v;
  1365.                     preplot8[j][2] = (**w_objs_hndl).bg_object[7]._3dPt_BG[j].z_point;
  1366.                     preplot8[j][3] = (**w_objs_hndl).bg_object[7]._3dPt_BG[j].no_point;
  1367.                 }
  1368.                 /*    transform to relative VRP    */
  1369.                 for(j = 0;j <= 7;j++)
  1370.                 {
  1371.                     for(k = 0;k <= 3;k++)
  1372.                     {
  1373.                         xForm8[j][k] = 0.0;                
  1374.                     }
  1375.                 }
  1376.                 
  1377.                 VRPxform[0][3] = -1.0 * xVan;
  1378.                 VRPxform[1][3] = -1.0 * yVan;
  1379.                 
  1380.                 for(j = 0;j <= 7;j++)
  1381.                 {
  1382.                     for(k = 0;k <= 3;k++)
  1383.                     {
  1384.                         for(i = 0;i <= 3;i++)
  1385.                         {
  1386.                             xForm8[j][k] += VRPxform[k][i] * preplot8[j][i];                
  1387.                         }
  1388.                     }
  1389.                 }
  1390.                 /* first create and initialize persMat    */
  1391.                 for(j = 0;j <= 7;j++)                                                                    /*    Create the translation matrices    */
  1392.                 {
  1393.                     for(k = 0;k <= 3;k++)
  1394.                     {
  1395.                         for(m = 0;m <= 3;m++)
  1396.                         {
  1397.                             if(m == k)    pers8Mat[j][k][m] = 1;
  1398.                             else        pers8Mat[j][k][m] = 0;
  1399.                         }
  1400.                     }
  1401.                 }
  1402.                 for(j = 0;j <= 7;j++)        /*    cause eight vertices in the object    */
  1403.                 {
  1404.                     Wtemp8[j] = (xForm8[j][2]) / zScale;                                                            /*    tenth try    */
  1405.                 }
  1406.                 for(m = 0;m <= 7;m++)
  1407.                 {
  1408.                     for(k = 0;k <= 2;k++)
  1409.                     {
  1410.                         newPers8Vect[m][k] = 0;
  1411.                     }
  1412.                     newPers8Vect[m][3] = 1;
  1413.                 }
  1414.                 for(m = 0;m <= 7;m++)    // which vertex
  1415.                 {
  1416.                                                 /*      *---------------- vertice point    */
  1417.                                                 /*    |  *------------- row                */
  1418.                     for(k = 0;k <= 2;k++)        /*      |  |          *-- vertice point    */
  1419.                     {                            /*      v  v          v                            */
  1420.                         newPers8Vect[m][k]    =  xForm8[m][k]/(Wtemp8[m]);
  1421.                     }
  1422.                 }
  1423.                 /*    transform back from VRP    */
  1424.  
  1425.                 VRPxform[0][3] = xVan;
  1426.                 VRPxform[1][3] = yVan;
  1427.                 
  1428.                 for(j = 0;j <= 7;j++)
  1429.                 {
  1430.                     for(k = 0;k <= 3;k++)
  1431.                     {
  1432.                         xForm8[j][k] = 0;                
  1433.                     }
  1434.                 }
  1435.  
  1436.                 for(j = 0;j <= 7;j++)
  1437.                 {
  1438.                     for(k = 0;k <= 3;k++)
  1439.                     {
  1440.                         for(i = 0;i <= 3;i++)
  1441.                         {
  1442.                             xForm8[j][k] += VRPxform[k][i] * newPers8Vect[j][i];                
  1443.                         }
  1444.                     }
  1445.                 }
  1446.                 for(j = 0;j <= 7;j++)
  1447.                 {
  1448.                     for(k = 0;k <= 3;k++)
  1449.                     {
  1450.                         newPers8Vect[j][k] = xForm8[j][k];
  1451.                     }
  1452.                 }
  1453.                 MoveTo(newPers8Vect[0][0],newPers8Vect[0][1]);            /*    second cube    */
  1454.                 thePoly = OpenPoly();
  1455.                 LineTo(newPers8Vect[1][0],newPers8Vect[1][1]);
  1456.                 LineTo(newPers8Vect[2][0],newPers8Vect[2][1]);
  1457.                 LineTo(newPers8Vect[3][0],newPers8Vect[3][1]);
  1458.                 LineTo(newPers8Vect[0][0],newPers8Vect[0][1]);
  1459.                 ClosePoly();
  1460.                 FillPoly( thePoly,&qd.gray);
  1461.                 LineTo(newPers8Vect[4][0],newPers8Vect[4][1]);
  1462.                 thePoly = OpenPoly();
  1463.                 LineTo(newPers8Vect[5][0],newPers8Vect[5][1]);
  1464.                 LineTo(newPers8Vect[6][0],newPers8Vect[6][1]);
  1465.                 LineTo(newPers8Vect[7][0],newPers8Vect[7][1]);
  1466.                 LineTo(newPers8Vect[4][0],newPers8Vect[4][1]);
  1467.                 ClosePoly();
  1468.                 FillPoly( thePoly,&qd.black);
  1469.                 MoveTo(newPers8Vect[1][0],newPers8Vect[1][1]);
  1470.                 LineTo(newPers8Vect[5][0],newPers8Vect[5][1]);
  1471.                 MoveTo(newPers8Vect[2][0],newPers8Vect[2][1]);
  1472.                 LineTo(newPers8Vect[6][0],newPers8Vect[6][1]);
  1473.                 MoveTo(newPers8Vect[3][0],newPers8Vect[3][1]);
  1474.                 LineTo(newPers8Vect[7][0],newPers8Vect[7][1]);                
  1475.                 
  1476.             }
  1477.             else if (!noShow)        // if(!debugPers)
  1478.             {
  1479.                 MoveTo((**w_objs_hndl).bg_object[7]._3dPt_BG[0].x_point -offset.h,                /*    second cube    */
  1480.                         (**w_objs_hndl).bg_object[7]._3dPt_BG[0].y_point -offset.v);
  1481.                 LineTo((**w_objs_hndl).bg_object[7]._3dPt_BG[1].x_point -offset.h,
  1482.                         (**w_objs_hndl).bg_object[7]._3dPt_BG[1].y_point -offset.v);
  1483.                 LineTo((**w_objs_hndl).bg_object[7]._3dPt_BG[2].x_point -offset.h,
  1484.                         (**w_objs_hndl).bg_object[7]._3dPt_BG[2].y_point -offset.v);
  1485.                 LineTo((**w_objs_hndl).bg_object[7]._3dPt_BG[3].x_point -offset.h,
  1486.                         (**w_objs_hndl).bg_object[7]._3dPt_BG[3].y_point -offset.v);
  1487.                 LineTo((**w_objs_hndl).bg_object[7]._3dPt_BG[0].x_point -offset.h,
  1488.                         (**w_objs_hndl).bg_object[7]._3dPt_BG[0].y_point -offset.v);
  1489.                 LineTo((**w_objs_hndl).bg_object[7]._3dPt_BG[4].x_point -offset.h,
  1490.                         (**w_objs_hndl).bg_object[7]._3dPt_BG[4].y_point -offset.v);
  1491.                 LineTo((**w_objs_hndl).bg_object[7]._3dPt_BG[5].x_point -offset.h,
  1492.                         (**w_objs_hndl).bg_object[7]._3dPt_BG[5].y_point -offset.v);
  1493.                 LineTo((**w_objs_hndl).bg_object[7]._3dPt_BG[6].x_point -offset.h,
  1494.                         (**w_objs_hndl).bg_object[7]._3dPt_BG[6].y_point -offset.v);
  1495.                 LineTo((**w_objs_hndl).bg_object[7]._3dPt_BG[7].x_point -offset.h,
  1496.                         (**w_objs_hndl).bg_object[7]._3dPt_BG[7].y_point -offset.v);
  1497.                 LineTo((**w_objs_hndl).bg_object[7]._3dPt_BG[4].x_point -offset.h,
  1498.                         (**w_objs_hndl).bg_object[7]._3dPt_BG[4].y_point -offset.v);
  1499.                 MoveTo((**w_objs_hndl).bg_object[7]._3dPt_BG[1].x_point -offset.h,
  1500.                         (**w_objs_hndl).bg_object[7]._3dPt_BG[1].y_point -offset.v);
  1501.                 LineTo((**w_objs_hndl).bg_object[7]._3dPt_BG[5].x_point -offset.h,
  1502.                         (**w_objs_hndl).bg_object[7]._3dPt_BG[5].y_point -offset.v);
  1503.                 MoveTo((**w_objs_hndl).bg_object[7]._3dPt_BG[2].x_point -offset.h,
  1504.                         (**w_objs_hndl).bg_object[7]._3dPt_BG[2].y_point -offset.v);
  1505.                 LineTo((**w_objs_hndl).bg_object[7]._3dPt_BG[6].x_point -offset.h,
  1506.                         (**w_objs_hndl).bg_object[7]._3dPt_BG[6].y_point -offset.v);
  1507.                 MoveTo((**w_objs_hndl).bg_object[7]._3dPt_BG[3].x_point -offset.h,
  1508.                         (**w_objs_hndl).bg_object[7]._3dPt_BG[3].y_point -offset.v);
  1509.                 LineTo((**w_objs_hndl).bg_object[7]._3dPt_BG[7].x_point -offset.h,
  1510.                         (**w_objs_hndl).bg_object[7]._3dPt_BG[7].y_point -offset.v);
  1511.             }
  1512.         }
  1513.         if(    (**w_objs_hndl).bg_object[8]._3dPt_BG[0].z_point < 0 &&                /*    third cube    */
  1514.             (**w_objs_hndl).bg_object[8]._3dPt_BG[1].z_point < 0 &&
  1515.             (**w_objs_hndl).bg_object[8]._3dPt_BG[2].z_point < 0 &&
  1516.             (**w_objs_hndl).bg_object[8]._3dPt_BG[3].z_point < 0 &&
  1517.             (**w_objs_hndl).bg_object[8]._3dPt_BG[4].z_point < 0 &&
  1518.             (**w_objs_hndl).bg_object[8]._3dPt_BG[5].z_point < 0 &&
  1519.             (**w_objs_hndl).bg_object[8]._3dPt_BG[6].z_point < 0 &&
  1520.             (**w_objs_hndl).bg_object[8]._3dPt_BG[7].z_point < 0)
  1521.         {
  1522.             if(doPers && !debugPers)
  1523.             {
  1524.                 for(j = 0;j <= 7;j++)    /*    j is point in the object    */
  1525.                 {                        /*    0••7 cause 8 points in a cube or column    */
  1526.                     preplot8[j][0] = (**w_objs_hndl).bg_object[8]._3dPt_BG[j].x_point -offset.h;
  1527.                     preplot8[j][1] = (**w_objs_hndl).bg_object[8]._3dPt_BG[j].y_point -offset.v;
  1528.                     preplot8[j][2] = (**w_objs_hndl).bg_object[8]._3dPt_BG[j].z_point;
  1529.                     preplot8[j][3] = (**w_objs_hndl).bg_object[8]._3dPt_BG[j].no_point;
  1530.                 }
  1531.                 /*    transform to relative VRP    */
  1532.                 for(j = 0;j <= 7;j++)
  1533.                 {
  1534.                     for(k = 0;k <= 3;k++)
  1535.                     {
  1536.                         xForm8[j][k] = 0.0;                
  1537.                     }
  1538.                 }
  1539.                 
  1540.                 VRPxform[0][3] = -1.0 * xVan;
  1541.                 VRPxform[1][3] = -1.0 * yVan;
  1542.                 
  1543.                 for(j = 0;j <= 7;j++)
  1544.                 {
  1545.                     for(k = 0;k <= 3;k++)
  1546.                     {
  1547.                         for(i = 0;i <= 3;i++)
  1548.                         {
  1549.                             xForm8[j][k] += VRPxform[k][i] * preplot8[j][i];                
  1550.                         }
  1551.                     }
  1552.                 }
  1553.                 /* first create and initialize persMat    */
  1554.                 for(j = 0;j <= 7;j++)                                                                    /*    Create the translation matrices    */
  1555.                 {
  1556.                     for(k = 0;k <= 3;k++)
  1557.                     {
  1558.                         for(m = 0;m <= 3;m++)
  1559.                         {
  1560.                             if(m == k)    pers8Mat[j][k][m] = 1;
  1561.                             else        pers8Mat[j][k][m] = 0;
  1562.                         }
  1563.                     }
  1564.                 }
  1565.                 for(j = 0;j <= 7;j++)        /*    cause eight vertices in the object    */
  1566.                 {
  1567.                     Wtemp8[j] = (xForm8[j][2]) / zScale;                                                            /*    tenth try    */
  1568.                 }
  1569.                 for(m = 0;m <= 7;m++)
  1570.                 {
  1571.                     for(k = 0;k <= 2;k++)
  1572.                     {
  1573.                         newPers8Vect[m][k] = 0;
  1574.                     }
  1575.                     newPers8Vect[m][3] = 1;
  1576.                 }
  1577.                 for(m = 0;m <= 7;m++)    // which vertex
  1578.                 {
  1579.                                                 /*      *---------------- vertice point    */
  1580.                                                 /*    |  *------------- row                */
  1581.                     for(k = 0;k <= 2;k++)        /*      |  |          *-- vertice point    */
  1582.                     {                            /*      v  v          v                            */
  1583.                         newPers8Vect[m][k]    =  xForm8[m][k]/(Wtemp8[m]);
  1584.                     }
  1585.                 }
  1586.                 /*    transform back from VRP    */
  1587.  
  1588.                 VRPxform[0][3] = xVan;
  1589.                 VRPxform[1][3] = yVan;
  1590.                 
  1591.                 for(j = 0;j <= 7;j++)
  1592.                 {
  1593.                     for(k = 0;k <= 3;k++)
  1594.                     {
  1595.                         xForm8[j][k] = 0;                
  1596.                     }
  1597.                 }
  1598.  
  1599.                 for(j = 0;j <= 7;j++)
  1600.                 {
  1601.                     for(k = 0;k <= 3;k++)
  1602.                     {
  1603.                         for(i = 0;i <= 3;i++)
  1604.                         {
  1605.                             xForm8[j][k] += VRPxform[k][i] * newPers8Vect[j][i];                
  1606.                         }
  1607.                     }
  1608.                 }
  1609.                 for(j = 0;j <= 7;j++)
  1610.                 {
  1611.                     for(k = 0;k <= 3;k++)
  1612.                     {
  1613.                         newPers8Vect[j][k] = xForm8[j][k];
  1614.                     }
  1615.                 }
  1616.                 MoveTo(newPers8Vect[0][0],newPers8Vect[0][1]);            /*    third cube    */
  1617.                 thePoly = OpenPoly();
  1618.                 LineTo(newPers8Vect[1][0],newPers8Vect[1][1]);
  1619.                 LineTo(newPers8Vect[2][0],newPers8Vect[2][1]);
  1620.                 LineTo(newPers8Vect[3][0],newPers8Vect[3][1]);
  1621.                 LineTo(newPers8Vect[0][0],newPers8Vect[0][1]);
  1622.                 ClosePoly();
  1623.                 FillPoly( thePoly,&qd.black);
  1624.                 thePoly = OpenPoly();
  1625.                 LineTo(newPers8Vect[4][0],newPers8Vect[4][1]);
  1626.                 LineTo(newPers8Vect[7][0],newPers8Vect[7][1]);
  1627.                 LineTo(newPers8Vect[3][0],newPers8Vect[3][1]);
  1628.                 LineTo(newPers8Vect[0][0],newPers8Vect[0][1]);
  1629.                 ClosePoly();
  1630.                 FillPoly( thePoly,&qd.gray);
  1631.                 MoveTo(newPers8Vect[1][0],newPers8Vect[1][1]);
  1632.                 thePoly = OpenPoly();
  1633.                 LineTo(newPers8Vect[5][0],newPers8Vect[5][1]);
  1634.                 LineTo(newPers8Vect[6][0],newPers8Vect[6][1]);
  1635.                 LineTo(newPers8Vect[2][0],newPers8Vect[2][1]);
  1636.                 LineTo(newPers8Vect[1][0],newPers8Vect[1][1]);
  1637.                 ClosePoly();
  1638.                 FillPoly( thePoly,&qd.black);
  1639.                 MoveTo(newPers8Vect[4][0],newPers8Vect[4][1]);
  1640.                 LineTo(newPers8Vect[5][0],newPers8Vect[5][1]);
  1641.                 MoveTo(newPers8Vect[6][0],newPers8Vect[6][1]);
  1642.                 LineTo(newPers8Vect[7][0],newPers8Vect[7][1]);        
  1643.                         
  1644. /*                LineTo(newPers8Vect[4][0],newPers8Vect[4][1]);
  1645.                 LineTo(newPers8Vect[5][0],newPers8Vect[5][1]);
  1646.                 LineTo(newPers8Vect[6][0],newPers8Vect[6][1]);
  1647.                 LineTo(newPers8Vect[7][0],newPers8Vect[7][1]);
  1648.                 LineTo(newPers8Vect[4][0],newPers8Vect[4][1]);
  1649.                 MoveTo(newPers8Vect[1][0],newPers8Vect[1][1]);
  1650.                 LineTo(newPers8Vect[5][0],newPers8Vect[5][1]);
  1651.                 MoveTo(newPers8Vect[2][0],newPers8Vect[2][1]);
  1652.                 LineTo(newPers8Vect[6][0],newPers8Vect[6][1]);
  1653.                 MoveTo(newPers8Vect[3][0],newPers8Vect[3][1]);
  1654.                 LineTo(newPers8Vect[7][0],newPers8Vect[7][1]);                */
  1655.             }
  1656.             else    // if (!noShow)        // if(!debugPers)
  1657.             {
  1658.                 MoveTo((**w_objs_hndl).bg_object[8]._3dPt_BG[0].x_point -offset.h,                /*    third cube    */
  1659.                         (**w_objs_hndl).bg_object[8]._3dPt_BG[0].y_point -offset.v);
  1660.                 LineTo((**w_objs_hndl).bg_object[8]._3dPt_BG[1].x_point -offset.h,
  1661.                         (**w_objs_hndl).bg_object[8]._3dPt_BG[1].y_point -offset.v);
  1662.                 LineTo((**w_objs_hndl).bg_object[8]._3dPt_BG[2].x_point -offset.h,
  1663.                         (**w_objs_hndl).bg_object[8]._3dPt_BG[2].y_point -offset.v);
  1664.                 LineTo((**w_objs_hndl).bg_object[8]._3dPt_BG[3].x_point -offset.h,
  1665.                         (**w_objs_hndl).bg_object[8]._3dPt_BG[3].y_point -offset.v);
  1666.                 LineTo((**w_objs_hndl).bg_object[8]._3dPt_BG[0].x_point -offset.h,
  1667.                         (**w_objs_hndl).bg_object[8]._3dPt_BG[0].y_point -offset.v);
  1668.                 LineTo((**w_objs_hndl).bg_object[8]._3dPt_BG[4].x_point -offset.h,
  1669.                         (**w_objs_hndl).bg_object[8]._3dPt_BG[4].y_point -offset.v);
  1670.                 LineTo((**w_objs_hndl).bg_object[8]._3dPt_BG[5].x_point -offset.h,
  1671.                         (**w_objs_hndl).bg_object[8]._3dPt_BG[5].y_point -offset.v);
  1672.                 LineTo((**w_objs_hndl).bg_object[8]._3dPt_BG[6].x_point -offset.h,
  1673.                         (**w_objs_hndl).bg_object[8]._3dPt_BG[6].y_point -offset.v);
  1674.                 LineTo((**w_objs_hndl).bg_object[8]._3dPt_BG[7].x_point -offset.h,
  1675.                         (**w_objs_hndl).bg_object[8]._3dPt_BG[7].y_point -offset.v);
  1676.                 LineTo((**w_objs_hndl).bg_object[8]._3dPt_BG[4].x_point -offset.h,
  1677.                         (**w_objs_hndl).bg_object[8]._3dPt_BG[4].y_point -offset.v);
  1678.                 MoveTo((**w_objs_hndl).bg_object[8]._3dPt_BG[1].x_point -offset.h,
  1679.                         (**w_objs_hndl).bg_object[8]._3dPt_BG[1].y_point -offset.v);
  1680.                 LineTo((**w_objs_hndl).bg_object[8]._3dPt_BG[5].x_point -offset.h,
  1681.                         (**w_objs_hndl).bg_object[8]._3dPt_BG[5].y_point -offset.v);
  1682.                 MoveTo((**w_objs_hndl).bg_object[8]._3dPt_BG[2].x_point -offset.h,
  1683.                         (**w_objs_hndl).bg_object[8]._3dPt_BG[2].y_point -offset.v);
  1684.                 LineTo((**w_objs_hndl).bg_object[8]._3dPt_BG[6].x_point -offset.h,
  1685.                         (**w_objs_hndl).bg_object[8]._3dPt_BG[6].y_point -offset.v);
  1686.                 MoveTo((**w_objs_hndl).bg_object[8]._3dPt_BG[3].x_point -offset.h,
  1687.                         (**w_objs_hndl).bg_object[8]._3dPt_BG[3].y_point -offset.v);
  1688.                 LineTo((**w_objs_hndl).bg_object[8]._3dPt_BG[7].x_point -offset.h,
  1689.                         (**w_objs_hndl).bg_object[8]._3dPt_BG[7].y_point -offset.v);
  1690.             }
  1691.         }
  1692.         if(    (**w_objs_hndl).bg_object[9]._3dPt_BG[0].z_point < 0 &&            /*    fourth cube    */
  1693.             (**w_objs_hndl).bg_object[9]._3dPt_BG[1].z_point < 0 &&
  1694.             (**w_objs_hndl).bg_object[9]._3dPt_BG[2].z_point < 0 &&
  1695.             (**w_objs_hndl).bg_object[9]._3dPt_BG[3].z_point < 0 &&
  1696.             (**w_objs_hndl).bg_object[9]._3dPt_BG[4].z_point < 0 &&
  1697.             (**w_objs_hndl).bg_object[9]._3dPt_BG[5].z_point < 0 &&
  1698.             (**w_objs_hndl).bg_object[9]._3dPt_BG[6].z_point < 0 &&
  1699.             (**w_objs_hndl).bg_object[9]._3dPt_BG[7].z_point < 0)
  1700.         {
  1701.             if(doPers && !debugPers)
  1702.             {
  1703.                 for(j = 0;j <= 7;j++)    /*    j is point in the object    */
  1704.                 {                        /*    0••7 cause 8 points in a cube or column    */
  1705.                     preplot8[j][0] = (**w_objs_hndl).bg_object[9]._3dPt_BG[j].x_point -offset.h;
  1706.                     preplot8[j][1] = (**w_objs_hndl).bg_object[9]._3dPt_BG[j].y_point -offset.v;
  1707.                     preplot8[j][2] = (**w_objs_hndl).bg_object[9]._3dPt_BG[j].z_point;
  1708.                     preplot8[j][3] = (**w_objs_hndl).bg_object[9]._3dPt_BG[j].no_point;
  1709.                 }
  1710.                 /*    transform to relative VRP    */
  1711.                 for(j = 0;j <= 7;j++)
  1712.                 {
  1713.                     for(k = 0;k <= 3;k++)
  1714.                     {
  1715.                         xForm8[j][k] = 0.0;                
  1716.                     }
  1717.                 }
  1718.                 
  1719.                 VRPxform[0][3] = -1.0 * xVan;
  1720.                 VRPxform[1][3] = -1.0 * yVan;
  1721.                 
  1722.                 for(j = 0;j <= 7;j++)
  1723.                 {
  1724.                     for(k = 0;k <= 3;k++)
  1725.                     {
  1726.                         for(i = 0;i <= 3;i++)
  1727.                         {
  1728.                             xForm8[j][k] += VRPxform[k][i] * preplot8[j][i];                
  1729.                         }
  1730.                     }
  1731.                 }
  1732.                 /* first create and initialize persMat    */
  1733.                 for(j = 0;j <= 7;j++)                                                                    /*    Create the translation matrices    */
  1734.                 {
  1735.                     for(k = 0;k <= 3;k++)
  1736.                     {
  1737.                         for(m = 0;m <= 3;m++)
  1738.                         {
  1739.                             if(m == k)    pers8Mat[j][k][m] = 1;
  1740.                             else        pers8Mat[j][k][m] = 0;
  1741.                         }
  1742.                     }
  1743.                 }
  1744.                 for(j = 0;j <= 7;j++)        /*    cause eight vertices in the object    */
  1745.                 {
  1746.                     Wtemp8[j] = (xForm8[j][2]) / zScale;                                                            /*    tenth try    */
  1747.                 }
  1748.                 for(m = 0;m <= 7;m++)
  1749.                 {
  1750.                     for(k = 0;k <= 2;k++)
  1751.                     {
  1752.                         newPers8Vect[m][k] = 0;
  1753.                     }
  1754.                     newPers8Vect[m][3] = 1;
  1755.                 }
  1756.                 for(m = 0;m <= 7;m++)    // which vertex
  1757.                 {
  1758.                                                 /*      *---------------- vertice point    */
  1759.                                                 /*    |  *------------- row                */
  1760.                     for(k = 0;k <= 2;k++)        /*      |  |          *-- vertice point    */
  1761.                     {                            /*      v  v          v                            */
  1762.                         newPers8Vect[m][k]    =  xForm8[m][k]/(Wtemp8[m]);
  1763.                     }
  1764.                 }
  1765.                 /*    transform back from VRP    */
  1766.  
  1767.                 VRPxform[0][3] = xVan;
  1768.                 VRPxform[1][3] = yVan;
  1769.                 
  1770.                 for(j = 0;j <= 7;j++)
  1771.                 {
  1772.                     for(k = 0;k <= 3;k++)
  1773.                     {
  1774.                         xForm8[j][k] = 0;                
  1775.                     }
  1776.                 }
  1777.  
  1778.                 for(j = 0;j <= 7;j++)
  1779.                 {
  1780.                     for(k = 0;k <= 3;k++)
  1781.                     {
  1782.                         for(i = 0;i <= 3;i++)
  1783.                         {
  1784.                             xForm8[j][k] += VRPxform[k][i] * newPers8Vect[j][i];                
  1785.                         }
  1786.                     }
  1787.                 }
  1788.                 for(j = 0;j <= 7;j++)
  1789.                 {
  1790.                     for(k = 0;k <= 3;k++)
  1791.                     {
  1792.                         newPers8Vect[j][k] = xForm8[j][k];
  1793.                     }
  1794.                 }
  1795.                 MoveTo(newPers8Vect[0][0],newPers8Vect[0][1]);            /*    fourth cube    */
  1796.                 thePoly = OpenPoly();
  1797.                 LineTo(newPers8Vect[1][0],newPers8Vect[1][1]);
  1798.                 LineTo(newPers8Vect[2][0],newPers8Vect[2][1]);
  1799.                 LineTo(newPers8Vect[3][0],newPers8Vect[3][1]);
  1800.                 LineTo(newPers8Vect[0][0],newPers8Vect[0][1]);
  1801.                 ClosePoly();
  1802.                 FillPoly( thePoly,&qd.black);
  1803.                 LineTo(newPers8Vect[4][0],newPers8Vect[4][1]);
  1804.                 thePoly = OpenPoly();
  1805.                 LineTo(newPers8Vect[5][0],newPers8Vect[5][1]);
  1806.                 LineTo(newPers8Vect[6][0],newPers8Vect[6][1]);
  1807.                 LineTo(newPers8Vect[7][0],newPers8Vect[7][1]);
  1808.                 LineTo(newPers8Vect[4][0],newPers8Vect[4][1]);
  1809.                 ClosePoly();
  1810.                 FillPoly( thePoly,&qd.black);
  1811.                 MoveTo(newPers8Vect[1][0],newPers8Vect[1][1]);
  1812.                 LineTo(newPers8Vect[5][0],newPers8Vect[5][1]);
  1813.                 MoveTo(newPers8Vect[2][0],newPers8Vect[2][1]);
  1814.                 LineTo(newPers8Vect[6][0],newPers8Vect[6][1]);
  1815.                 MoveTo(newPers8Vect[3][0],newPers8Vect[3][1]);
  1816.                 LineTo(newPers8Vect[7][0],newPers8Vect[7][1]);                
  1817.                 
  1818.             }
  1819.             else //    if (!noShow)         //if(!debugPers)
  1820.             {
  1821.                 MoveTo((**w_objs_hndl).bg_object[9]._3dPt_BG[0].x_point -offset.h,                /*    fourth cube    */
  1822.                         (**w_objs_hndl).bg_object[9]._3dPt_BG[0].y_point -offset.v);
  1823.                 LineTo((**w_objs_hndl).bg_object[9]._3dPt_BG[1].x_point -offset.h,
  1824.                         (**w_objs_hndl).bg_object[9]._3dPt_BG[1].y_point -offset.v);
  1825.                 LineTo((**w_objs_hndl).bg_object[9]._3dPt_BG[2].x_point -offset.h,
  1826.                         (**w_objs_hndl).bg_object[9]._3dPt_BG[2].y_point -offset.v);
  1827.                 LineTo((**w_objs_hndl).bg_object[9]._3dPt_BG[3].x_point -offset.h,
  1828.                         (**w_objs_hndl).bg_object[9]._3dPt_BG[3].y_point -offset.v);
  1829.                 LineTo((**w_objs_hndl).bg_object[9]._3dPt_BG[0].x_point -offset.h,
  1830.                         (**w_objs_hndl).bg_object[9]._3dPt_BG[0].y_point -offset.v);
  1831.                 LineTo((**w_objs_hndl).bg_object[9]._3dPt_BG[4].x_point -offset.h,
  1832.                         (**w_objs_hndl).bg_object[9]._3dPt_BG[4].y_point -offset.v);
  1833.                 LineTo((**w_objs_hndl).bg_object[9]._3dPt_BG[5].x_point -offset.h,
  1834.                         (**w_objs_hndl).bg_object[9]._3dPt_BG[5].y_point -offset.v);
  1835.                 LineTo((**w_objs_hndl).bg_object[9]._3dPt_BG[6].x_point -offset.h,
  1836.                         (**w_objs_hndl).bg_object[9]._3dPt_BG[6].y_point -offset.v);
  1837.                 LineTo((**w_objs_hndl).bg_object[9]._3dPt_BG[7].x_point -offset.h,
  1838.                         (**w_objs_hndl).bg_object[9]._3dPt_BG[7].y_point -offset.v);
  1839.                 LineTo((**w_objs_hndl).bg_object[9]._3dPt_BG[4].x_point -offset.h,
  1840.                         (**w_objs_hndl).bg_object[9]._3dPt_BG[4].y_point -offset.v);
  1841.                 MoveTo((**w_objs_hndl).bg_object[9]._3dPt_BG[1].x_point -offset.h,
  1842.                         (**w_objs_hndl).bg_object[9]._3dPt_BG[1].y_point -offset.v);
  1843.                 LineTo((**w_objs_hndl).bg_object[9]._3dPt_BG[5].x_point -offset.h,
  1844.                         (**w_objs_hndl).bg_object[9]._3dPt_BG[5].y_point -offset.v);
  1845.                 MoveTo((**w_objs_hndl).bg_object[9]._3dPt_BG[2].x_point -offset.h,
  1846.                         (**w_objs_hndl).bg_object[9]._3dPt_BG[2].y_point -offset.v);
  1847.                 LineTo((**w_objs_hndl).bg_object[9]._3dPt_BG[6].x_point -offset.h,
  1848.                         (**w_objs_hndl).bg_object[9]._3dPt_BG[6].y_point -offset.v);
  1849.                 MoveTo((**w_objs_hndl).bg_object[9]._3dPt_BG[3].x_point -offset.h,
  1850.                         (**w_objs_hndl).bg_object[9]._3dPt_BG[3].y_point -offset.v);
  1851.                 LineTo((**w_objs_hndl).bg_object[9]._3dPt_BG[7].x_point -offset.h,
  1852.                         (**w_objs_hndl).bg_object[9]._3dPt_BG[7].y_point -offset.v);
  1853.             }                /*    end of fourth cube    */
  1854.         }
  1855.         if(    (**w_objs_hndl).bg_object[10]._3dPt_BG[0].z_point < 0 &&
  1856.             (**w_objs_hndl).bg_object[10]._3dPt_BG[1].z_point < 0 &&
  1857.             (**w_objs_hndl).bg_object[10]._3dPt_BG[2].z_point < 0)
  1858.         {
  1859.             if(doPers)
  1860.             {
  1861.                 for(j = 0;j <= 2;j++)            /*    0••2 cause 3 points for a triangle    */
  1862.                 {
  1863.                     preplot3[j][0] = (**w_objs_hndl).bg_object[10]._3dPt_BG[j].x_point -offset.h;
  1864.                     preplot3[j][1] = (**w_objs_hndl).bg_object[10]._3dPt_BG[j].y_point -offset.v;
  1865.                     preplot3[j][2] = (**w_objs_hndl).bg_object[10]._3dPt_BG[j].z_point;
  1866.                     preplot3[j][3] = (**w_objs_hndl).bg_object[10]._3dPt_BG[j].no_point;
  1867.                 }
  1868.                 /*    transform to relative VRP    */
  1869.                 for(j = 0;j <= 2;j++)        /*    initialize xForm3    */
  1870.                 {
  1871.                     for(k = 0;k <= 3;k++)
  1872.                     {
  1873.                         xForm3[j][k] = 0.0;                
  1874.                     }
  1875.                 }
  1876.                         /*    set VRP    */
  1877.         
  1878.                 VRPxform[0][3] = -1.0 * xVan;
  1879.                 VRPxform[1][3] = -1.0 * yVan;
  1880.  
  1881.                 for(j = 0;j <= 2;j++)
  1882.                 {
  1883.                     for(k = 0;k <= 3;k++)
  1884.                     {
  1885.                         for(i = 0;i <= 3;i++)
  1886.                         {
  1887.                             xForm3[j][k] += VRPxform[k][i] * preplot3[j][i];                
  1888.                         }
  1889.                     }
  1890.                 }                /* first create persMat    */
  1891.                 for(j = 0;j <= 2;j++)
  1892.                 {
  1893.                     for(k = 0;k <= 3;k++)
  1894.                     {
  1895.                         for(m = 0;m <= 3;m++)
  1896.                         {
  1897.                             if(m == k)    pers3Mat[j][k][m] = 1;
  1898.                             else        pers3Mat[j][k][m] = 0;
  1899.                         }
  1900.                     }
  1901.                 }
  1902.                 for(j = 0;j <= 2;j++)        /*    cause three vertices in the object    */
  1903.                 {
  1904.                     Wtemp3[j] = (xForm3[j][2]) / zScale;                /*    tenth try    */
  1905.                 }
  1906.                 for(m = 0;m <= 2;m++)
  1907.                 {
  1908.                     for(k = 0;k <= 2;k++)
  1909.                     {
  1910.                         newPers3Vect[m][k] = 0;
  1911.                     }
  1912.                     newPers3Vect[m][3] = 1;
  1913.                 }
  1914.                 for(m = 0;m <= 2;m++)            /*      *-------------- vertice point    */
  1915.                 {                                /*    |  *----------- column        */
  1916.                     for(k = 0;k <= 2;k++)        /*      |  |  *-------- vertice point */
  1917.                     {                            /*      v  v  v                        */
  1918.                         newPers3Vect[m][k] =   xForm3[m][k]/(Wtemp3[m]);
  1919.                     }
  1920.                 }
  1921.                 /*    transform back from VRP    */
  1922.  
  1923.                 VRPxform[0][3] = xVan;
  1924.                 VRPxform[1][3] = yVan;
  1925.                 
  1926.                 for(j = 0;j <= 2;j++)
  1927.                 {
  1928.                     for(k = 0;k <= 3;k++)
  1929.                     {
  1930.                         xForm3[j][k] = 0;                
  1931.                     }
  1932.                 }
  1933.  
  1934.                 for(j = 0;j <= 2;j++)
  1935.                 {
  1936.                     for(k = 0;k <= 3;k++)
  1937.                     {
  1938.                         for(i = 0;i <= 3;i++)
  1939.                         {
  1940.                             xForm3[j][k] += VRPxform[k][i] * newPers3Vect[j][i];                
  1941.                         }
  1942.                     }
  1943.                 }
  1944.                 for(j = 0;j <= 2;j++)
  1945.                 {
  1946.                     for(k = 0;k <= 3;k++)
  1947.                     {
  1948.                         newPers3Vect[j][k] = xForm3[j][k];
  1949.                     }
  1950.                 }
  1951.                 MoveTo(newPers3Vect[0][0],newPers3Vect[0][1]);
  1952.                 LineTo(newPers3Vect[1][0],newPers3Vect[1][1]);
  1953.                 LineTo(newPers3Vect[2][0],newPers3Vect[2][1]);
  1954.                 LineTo(newPers3Vect[0][0],newPers3Vect[0][1]);
  1955.             }
  1956.             else if (!noShow)
  1957.             {                        /*    first triangle    */
  1958.                 MoveTo((**w_objs_hndl).bg_object[10]._3dPt_BG[0].x_point -offset.h,
  1959.                         (**w_objs_hndl).bg_object[10]._3dPt_BG[0].y_point -offset.v);
  1960.                 LineTo((**w_objs_hndl).bg_object[10]._3dPt_BG[1].x_point -offset.h,
  1961.                         (**w_objs_hndl).bg_object[10]._3dPt_BG[1].y_point -offset.v);
  1962.                 LineTo((**w_objs_hndl).bg_object[10]._3dPt_BG[2].x_point -offset.h,
  1963.                         (**w_objs_hndl).bg_object[10]._3dPt_BG[2].y_point -offset.v);
  1964.                 LineTo((**w_objs_hndl).bg_object[10]._3dPt_BG[0].x_point -offset.h,
  1965.                         (**w_objs_hndl).bg_object[10]._3dPt_BG[0].y_point -offset.v);
  1966.             }
  1967.         }
  1968.         if( (**w_objs_hndl).bg_object[11]._3dPt_BG[0].z_point < 0 &&
  1969.             (**w_objs_hndl).bg_object[11]._3dPt_BG[1].z_point < 0 &&
  1970.             (**w_objs_hndl).bg_object[11]._3dPt_BG[2].z_point < 0)
  1971.         {
  1972.             if(doPers)
  1973.             {
  1974.                 for(j = 0;j <= 2;j++)            /*    0••2 cause 3 points for a triangle    */
  1975.                 {
  1976.                     preplot3[j][0] = (**w_objs_hndl).bg_object[11]._3dPt_BG[j].x_point -offset.h;
  1977.                     preplot3[j][1] = (**w_objs_hndl).bg_object[11]._3dPt_BG[j].y_point -offset.v;
  1978.                     preplot3[j][2] = (**w_objs_hndl).bg_object[11]._3dPt_BG[j].z_point;
  1979.                     preplot3[j][3] = (**w_objs_hndl).bg_object[11]._3dPt_BG[j].no_point;
  1980.                 }
  1981.                 /*    transform to relative VRP    */
  1982.                 for(j = 0;j <= 2;j++)        /*    initialize xForm3    */
  1983.                 {
  1984.                     for(k = 0;k <= 3;k++)
  1985.                     {
  1986.                         xForm3[j][k] = 0.0;                
  1987.                     }
  1988.                 }
  1989.                         /*    set VRP    */
  1990.         
  1991.                 VRPxform[0][3] = -1.0 * xVan;
  1992.                 VRPxform[1][3] = -1.0 * yVan;
  1993.  
  1994.                 for(j = 0;j <= 2;j++)
  1995.                 {
  1996.                     for(k = 0;k <= 3;k++)
  1997.                     {
  1998.                         for(i = 0;i <= 3;i++)
  1999.                         {
  2000.                             xForm3[j][k] += VRPxform[k][i] * preplot3[j][i];                
  2001.                         }
  2002.                     }
  2003.                 }                /* first create persMat    */
  2004.                 for(j = 0;j <= 2;j++)
  2005.                 {
  2006.                     for(k = 0;k <= 3;k++)
  2007.                     {
  2008.                         for(m = 0;m <= 3;m++)
  2009.                         {
  2010.                             if(m == k)    pers3Mat[j][k][m] = 1;
  2011.                             else        pers3Mat[j][k][m] = 0;
  2012.                         }
  2013.                     }
  2014.                 }
  2015.                 for(j = 0;j <= 2;j++)        /*    cause three vertices in the object    */
  2016.                 {
  2017.                     Wtemp3[j] = (xForm3[j][2]) / zScale;                /*    tenth try    */
  2018.                 }
  2019.                 for(m = 0;m <= 2;m++)
  2020.                 {
  2021.                     for(k = 0;k <= 2;k++)
  2022.                     {
  2023.                         newPers3Vect[m][k] = 0;
  2024.                     }
  2025.                     newPers3Vect[m][3] = 1;
  2026.                 }
  2027.                 for(m = 0;m <= 2;m++)            /*      *-------------- vertice point    */
  2028.                 {                                /*    |  *----------- column        */
  2029.                     for(k = 0;k <= 2;k++)        /*      |  |  *-------- vertice point */
  2030.                     {                            /*      v  v  v                        */
  2031.                         newPers3Vect[m][k] =   xForm3[m][k]/(Wtemp3[m]);
  2032.                     }
  2033.                 }
  2034.                 /*    transform back from VRP    */
  2035.  
  2036.                 VRPxform[0][3] = xVan;
  2037.                 VRPxform[1][3] = yVan;
  2038.                 
  2039.                 for(j = 0;j <= 2;j++)
  2040.                 {
  2041.                     for(k = 0;k <= 3;k++)
  2042.                     {
  2043.                         xForm3[j][k] = 0;                
  2044.                     }
  2045.                 }
  2046.  
  2047.                 for(j = 0;j <= 2;j++)
  2048.                 {
  2049.                     for(k = 0;k <= 3;k++)
  2050.                     {
  2051.                         for(i = 0;i <= 3;i++)
  2052.                         {
  2053.                             xForm3[j][k] += VRPxform[k][i] * newPers3Vect[j][i];                
  2054.                         }
  2055.                     }
  2056.                 }
  2057.                 for(j = 0;j <= 2;j++)
  2058.                 {
  2059.                     for(k = 0;k <= 3;k++)
  2060.                     {
  2061.                         newPers3Vect[j][k] = xForm3[j][k];
  2062.                     }
  2063.                 }
  2064.                 MoveTo(newPers3Vect[0][0],newPers3Vect[0][1]);
  2065.                 thePoly = OpenPoly();
  2066.                 LineTo(newPers3Vect[1][0],newPers3Vect[1][1]);
  2067.                 LineTo(newPers3Vect[2][0],newPers3Vect[2][1]);
  2068.                 LineTo(newPers3Vect[0][0],newPers3Vect[0][1]);
  2069.                 ClosePoly();
  2070.                 FillPoly( thePoly,&qd.black);
  2071.             }
  2072.             else if (!noShow)
  2073.             {                            /*    second triangle    */
  2074.                 MoveTo((**w_objs_hndl).bg_object[11]._3dPt_BG[0].x_point -offset.h,
  2075.                         (**w_objs_hndl).bg_object[11]._3dPt_BG[0].y_point -offset.v);
  2076.                 LineTo((**w_objs_hndl).bg_object[11]._3dPt_BG[1].x_point -offset.h,
  2077.                         (**w_objs_hndl).bg_object[11]._3dPt_BG[1].y_point -offset.v);
  2078.                 LineTo((**w_objs_hndl).bg_object[11]._3dPt_BG[2].x_point -offset.h,
  2079.                         (**w_objs_hndl).bg_object[11]._3dPt_BG[2].y_point -offset.v);
  2080.                 LineTo((**w_objs_hndl).bg_object[11]._3dPt_BG[0].x_point -offset.h,
  2081.                         (**w_objs_hndl).bg_object[11]._3dPt_BG[0].y_point -offset.v);
  2082.             }
  2083.         }
  2084.         if(    (**w_objs_hndl).bg_object[12]._3dPt_BG[0].z_point < 0 &&
  2085.             (**w_objs_hndl).bg_object[12]._3dPt_BG[1].z_point < 0 &&
  2086.             (**w_objs_hndl).bg_object[12]._3dPt_BG[2].z_point < 0)
  2087.         {
  2088.             if(doPers)
  2089.             {
  2090.                 for(j = 0;j <= 2;j++)            /*    0••2 cause 3 points for a triangle    */
  2091.                 {
  2092.                     preplot3[j][0] = (**w_objs_hndl).bg_object[12]._3dPt_BG[j].x_point -offset.h;
  2093.                     preplot3[j][1] = (**w_objs_hndl).bg_object[12]._3dPt_BG[j].y_point -offset.v;
  2094.                     preplot3[j][2] = (**w_objs_hndl).bg_object[12]._3dPt_BG[j].z_point;
  2095.                     preplot3[j][3] = (**w_objs_hndl).bg_object[12]._3dPt_BG[j].no_point;
  2096.                 }
  2097.                 /*    transform to relative VRP    */
  2098.                 for(j = 0;j <= 2;j++)        /*    initialize xForm3    */
  2099.                 {
  2100.                     for(k = 0;k <= 3;k++)
  2101.                     {
  2102.                         xForm3[j][k] = 0.0;                
  2103.                     }
  2104.                 }
  2105.                         /*    set VRP    */
  2106.         
  2107.                 VRPxform[0][3] = -1.0 * xVan;
  2108.                 VRPxform[1][3] = -1.0 * yVan;
  2109.  
  2110.                 for(j = 0;j <= 2;j++)
  2111.                 {
  2112.                     for(k = 0;k <= 3;k++)
  2113.                     {
  2114.                         for(i = 0;i <= 3;i++)
  2115.                         {
  2116.                             xForm3[j][k] += VRPxform[k][i] * preplot3[j][i];                
  2117.                         }
  2118.                     }
  2119.                 }                /* first create persMat    */
  2120.                 for(j = 0;j <= 2;j++)
  2121.                 {
  2122.                     for(k = 0;k <= 3;k++)
  2123.                     {
  2124.                         for(m = 0;m <= 3;m++)
  2125.                         {
  2126.                             if(m == k)    pers3Mat[j][k][m] = 1;
  2127.                             else        pers3Mat[j][k][m] = 0;
  2128.                         }
  2129.                     }
  2130.                 }
  2131.                 for(j = 0;j <= 2;j++)        /*    cause three vertices in the object    */
  2132.                 {
  2133.                     Wtemp3[j] = (xForm3[j][2]) / zScale;                /*    tenth try    */
  2134.                 }
  2135.                 for(m = 0;m <= 2;m++)
  2136.                 {
  2137.                     for(k = 0;k <= 2;k++)
  2138.                     {
  2139.                         newPers3Vect[m][k] = 0;
  2140.                     }
  2141.                     newPers3Vect[m][3] = 1;
  2142.                 }
  2143.                 for(m = 0;m <= 2;m++)            /*      *-------------- vertice point    */
  2144.                 {                                /*    |  *----------- column        */
  2145.                     for(k = 0;k <= 2;k++)        /*      |  |  *-------- vertice point */
  2146.                     {                            /*      v  v  v                        */
  2147.                         newPers3Vect[m][k] =   xForm3[m][k]/(Wtemp3[m]);
  2148.                     }
  2149.                 }
  2150.                 /*    transform back from VRP    */
  2151.  
  2152.                 VRPxform[0][3] = xVan;
  2153.                 VRPxform[1][3] = yVan;
  2154.                 
  2155.                 for(j = 0;j <= 2;j++)
  2156.                 {
  2157.                     for(k = 0;k <= 3;k++)
  2158.                     {
  2159.                         xForm3[j][k] = 0;                
  2160.                     }
  2161.                 }
  2162.  
  2163.                 for(j = 0;j <= 2;j++)
  2164.                 {
  2165.                     for(k = 0;k <= 3;k++)
  2166.                     {
  2167.                         for(i = 0;i <= 3;i++)
  2168.                         {
  2169.                             xForm3[j][k] += VRPxform[k][i] * newPers3Vect[j][i];                
  2170.                         }
  2171.                     }
  2172.                 }
  2173.                 for(j = 0;j <= 2;j++)
  2174.                 {
  2175.                     for(k = 0;k <= 3;k++)
  2176.                     {
  2177.                         newPers3Vect[j][k] = xForm3[j][k];
  2178.                     }
  2179.                 }
  2180.                 MoveTo(newPers3Vect[0][0],newPers3Vect[0][1]);
  2181.                 thePoly = OpenPoly();
  2182.                 LineTo(newPers3Vect[1][0],newPers3Vect[1][1]);
  2183.                 LineTo(newPers3Vect[2][0],newPers3Vect[2][1]);
  2184.                 LineTo(newPers3Vect[0][0],newPers3Vect[0][1]);
  2185.                 ClosePoly();
  2186.                 FillPoly( thePoly,&qd.gray);            
  2187.             }
  2188.             else
  2189.             {                        /*    third triangle    */
  2190.                 MoveTo((**w_objs_hndl).bg_object[12]._3dPt_BG[0].x_point -offset.h,
  2191.                         (**w_objs_hndl).bg_object[12]._3dPt_BG[0].y_point -offset.v);
  2192.                 LineTo((**w_objs_hndl).bg_object[12]._3dPt_BG[1].x_point -offset.h,
  2193.                         (**w_objs_hndl).bg_object[12]._3dPt_BG[1].y_point -offset.v);
  2194.                 LineTo((**w_objs_hndl).bg_object[12]._3dPt_BG[2].x_point -offset.h,
  2195.                         (**w_objs_hndl).bg_object[12]._3dPt_BG[2].y_point -offset.v);
  2196.                 LineTo((**w_objs_hndl).bg_object[12]._3dPt_BG[0].x_point -offset.h,
  2197.                         (**w_objs_hndl).bg_object[12]._3dPt_BG[0].y_point -offset.v);
  2198.             }
  2199.         }
  2200.         if(    (**w_objs_hndl).bg_object[13]._3dPt_BG[0].z_point < 0 &&
  2201.             (**w_objs_hndl).bg_object[13]._3dPt_BG[1].z_point < 0 &&
  2202.             (**w_objs_hndl).bg_object[13]._3dPt_BG[2].z_point < 0)
  2203.         {
  2204.             if(doPers)
  2205.             {
  2206.                 for(j = 0;j <= 2;j++)            /*    0••2 cause 3 points for a triangle    */
  2207.                 {
  2208.                     preplot3[j][0] = (**w_objs_hndl).bg_object[13]._3dPt_BG[j].x_point -offset.h;
  2209.                     preplot3[j][1] = (**w_objs_hndl).bg_object[13]._3dPt_BG[j].y_point -offset.v;
  2210.                     preplot3[j][2] = (**w_objs_hndl).bg_object[13]._3dPt_BG[j].z_point;
  2211.                     preplot3[j][3] = (**w_objs_hndl).bg_object[13]._3dPt_BG[j].no_point;
  2212.                 }
  2213.                 /*    transform to relative VRP    */
  2214.                 for(j = 0;j <= 2;j++)        /*    initialize xForm3    */
  2215.                 {
  2216.                     for(k = 0;k <= 3;k++)
  2217.                     {
  2218.                         xForm3[j][k] = 0.0;                
  2219.                     }
  2220.                 }
  2221.                         /*    set VRP    */
  2222.         
  2223.                 VRPxform[0][3] = -1.0 * xVan;
  2224.                 VRPxform[1][3] = -1.0 * yVan;
  2225.  
  2226.                 for(j = 0;j <= 2;j++)
  2227.                 {
  2228.                     for(k = 0;k <= 3;k++)
  2229.                     {
  2230.                         for(i = 0;i <= 3;i++)
  2231.                         {
  2232.                             xForm3[j][k] += VRPxform[k][i] * preplot3[j][i];                
  2233.                         }
  2234.                     }
  2235.                 }                /* first create persMat    */
  2236.                 for(j = 0;j <= 2;j++)
  2237.                 {
  2238.                     for(k = 0;k <= 3;k++)
  2239.                     {
  2240.                         for(m = 0;m <= 3;m++)
  2241.                         {
  2242.                             if(m == k)    pers3Mat[j][k][m] = 1;
  2243.                             else        pers3Mat[j][k][m] = 0;
  2244.                         }
  2245.                     }
  2246.                 }
  2247.                 for(j = 0;j <= 2;j++)        /*    cause three vertices in the object    */
  2248.                 {
  2249.                     Wtemp3[j] = (xForm3[j][2]) / zScale;                /*    tenth try    */
  2250.                 }
  2251.                 for(m = 0;m <= 2;m++)
  2252.                 {
  2253.                     for(k = 0;k <= 2;k++)
  2254.                     {
  2255.                         newPers3Vect[m][k] = 0;
  2256.                     }
  2257.                     newPers3Vect[m][3] = 1;
  2258.                 }
  2259.                 for(m = 0;m <= 2;m++)            /*      *-------------- vertice point    */
  2260.                 {                                /*    |  *----------- column        */
  2261.                     for(k = 0;k <= 2;k++)        /*      |  |  *-------- vertice point */
  2262.                     {                            /*      v  v  v                        */
  2263.                         newPers3Vect[m][k] =   xForm3[m][k]/(Wtemp3[m]);
  2264.                     }
  2265.                 }
  2266.                 /*    transform back from VRP    */
  2267.  
  2268.                 VRPxform[0][3] = xVan;
  2269.                 VRPxform[1][3] = yVan;
  2270.                 
  2271.                 for(j = 0;j <= 2;j++)
  2272.                 {
  2273.                     for(k = 0;k <= 3;k++)
  2274.                     {
  2275.                         xForm3[j][k] = 0;                
  2276.                     }
  2277.                 }
  2278.  
  2279.                 for(j = 0;j <= 2;j++)
  2280.                 {
  2281.                     for(k = 0;k <= 3;k++)
  2282.                     {
  2283.                         for(i = 0;i <= 3;i++)
  2284.                         {
  2285.                             xForm3[j][k] += VRPxform[k][i] * newPers3Vect[j][i];                
  2286.                         }
  2287.                     }
  2288.                 }
  2289.                 for(j = 0;j <= 2;j++)
  2290.                 {
  2291.                     for(k = 0;k <= 3;k++)
  2292.                     {
  2293.                         newPers3Vect[j][k] = xForm3[j][k];
  2294.                     }
  2295.                 }
  2296.                 MoveTo(newPers3Vect[0][0],newPers3Vect[0][1]);
  2297.                 thePoly = OpenPoly();
  2298.                 LineTo(newPers3Vect[1][0],newPers3Vect[1][1]);
  2299.                 LineTo(newPers3Vect[2][0],newPers3Vect[2][1]);
  2300.                 LineTo(newPers3Vect[0][0],newPers3Vect[0][1]);
  2301.                 ClosePoly();
  2302.                 FillPoly( thePoly,&qd.gray);            
  2303.             }
  2304.             else
  2305.             {                    /*    fourth triangle    */
  2306.                 MoveTo((**w_objs_hndl).bg_object[13]._3dPt_BG[0].x_point -offset.h,
  2307.                         (**w_objs_hndl).bg_object[13]._3dPt_BG[0].y_point -offset.v);
  2308.                 LineTo((**w_objs_hndl).bg_object[13]._3dPt_BG[1].x_point -offset.h,
  2309.                         (**w_objs_hndl).bg_object[13]._3dPt_BG[1].y_point -offset.v);
  2310.                 LineTo((**w_objs_hndl).bg_object[13]._3dPt_BG[2].x_point -offset.h,
  2311.                         (**w_objs_hndl).bg_object[13]._3dPt_BG[2].y_point -offset.v);
  2312.                 LineTo((**w_objs_hndl).bg_object[13]._3dPt_BG[0].x_point -offset.h,
  2313.                         (**w_objs_hndl).bg_object[13]._3dPt_BG[0].y_point -offset.v);
  2314.             }
  2315.         }
  2316.         if(    (**w_objs_hndl).bg_object[14]._3dPt_BG[0].z_point < 0 &&
  2317.             (**w_objs_hndl).bg_object[14]._3dPt_BG[1].z_point < 0 &&
  2318.             (**w_objs_hndl).bg_object[14]._3dPt_BG[2].z_point < 0)
  2319.         {
  2320.             if(doPers && !debugPers)
  2321.             {
  2322.                 for(j = 0;j <= 2;j++)            /*    0••2 cause 3 points for a triangle    */
  2323.                 {
  2324.                     preplot3[j][0] = (**w_objs_hndl).bg_object[14]._3dPt_BG[j].x_point -offset.h;
  2325.                     preplot3[j][1] = (**w_objs_hndl).bg_object[14]._3dPt_BG[j].y_point -offset.v;
  2326.                     preplot3[j][2] = (**w_objs_hndl).bg_object[14]._3dPt_BG[j].z_point;
  2327.                     preplot3[j][3] = (**w_objs_hndl).bg_object[14]._3dPt_BG[j].no_point;
  2328.                 }
  2329.                 /*    transform to relative VRP    */
  2330.                 for(j = 0;j <= 2;j++)        /*    initialize xForm3    */
  2331.                 {
  2332.                     for(k = 0;k <= 3;k++)
  2333.                     {
  2334.                         xForm3[j][k] = 0.0;                
  2335.                     }
  2336.                 }
  2337.                         /*    set VRP    */
  2338.         
  2339.                 VRPxform[0][3] = -1.0 * xVan;
  2340.                 VRPxform[1][3] = -1.0 * yVan;
  2341.  
  2342.                 for(j = 0;j <= 2;j++)
  2343.                 {
  2344.                     for(k = 0;k <= 3;k++)
  2345.                     {
  2346.                         for(i = 0;i <= 3;i++)
  2347.                         {
  2348.                             xForm3[j][k] += VRPxform[k][i] * preplot3[j][i];                
  2349.                         }
  2350.                     }
  2351.                 }                /* first create persMat    */
  2352.                 for(j = 0;j <= 2;j++)
  2353.                 {
  2354.                     for(k = 0;k <= 3;k++)
  2355.                     {
  2356.                         for(m = 0;m <= 3;m++)
  2357.                         {
  2358.                             if(m == k)    pers3Mat[j][k][m] = 1;
  2359.                             else        pers3Mat[j][k][m] = 0;
  2360.                         }
  2361.                     }
  2362.                 }
  2363.                 for(j = 0;j <= 2;j++)        /*    cause three vertices in the object    */
  2364.                 {
  2365.                     Wtemp3[j] = (xForm3[j][2]) / zScale;                /*    tenth try    */
  2366.                 }
  2367.                 for(m = 0;m <= 2;m++)
  2368.                 {
  2369.                     for(k = 0;k <= 2;k++)
  2370.                     {
  2371.                         newPers3Vect[m][k] = 0;
  2372.                     }
  2373.                     newPers3Vect[m][3] = 1;
  2374.                 }
  2375.                 for(m = 0;m <= 2;m++)            /*      *-------------- vertice point    */
  2376.                 {                                /*    |  *----------- column        */
  2377.                     for(k = 0;k <= 2;k++)        /*      |  |  *-------- vertice point */
  2378.                     {                            /*      v  v  v                        */
  2379.                         newPers3Vect[m][k] =   xForm3[m][k]/(Wtemp3[m]);
  2380.                     }
  2381.                 }
  2382.                 /*    transform back from VRP    */
  2383.  
  2384.                 VRPxform[0][3] = xVan;
  2385.                 VRPxform[1][3] = yVan;
  2386.                 
  2387.                 for(j = 0;j <= 2;j++)
  2388.                 {
  2389.                     for(k = 0;k <= 3;k++)
  2390.                     {
  2391.                         xForm3[j][k] = 0;                
  2392.                     }
  2393.                 }
  2394.  
  2395.                 for(j = 0;j <= 2;j++)
  2396.                 {
  2397.                     for(k = 0;k <= 3;k++)
  2398.                     {
  2399.                         for(i = 0;i <= 3;i++)
  2400.                         {
  2401.                             xForm3[j][k] += VRPxform[k][i] * newPers3Vect[j][i];                
  2402.                         }
  2403.                     }
  2404.                 }
  2405.                 for(j = 0;j <= 2;j++)
  2406.                 {
  2407.                     for(k = 0;k <= 3;k++)
  2408.                     {
  2409.                         newPers3Vect[j][k] = xForm3[j][k];
  2410.                     }
  2411.                 }
  2412.                 MoveTo(newPers3Vect[0][0],newPers3Vect[0][1]);
  2413.                 thePoly = OpenPoly();
  2414.                 LineTo(newPers3Vect[1][0],newPers3Vect[1][1]);
  2415.                 LineTo(newPers3Vect[2][0],newPers3Vect[2][1]);
  2416.                 LineTo(newPers3Vect[0][0],newPers3Vect[0][1]);
  2417.                 ClosePoly();
  2418.                 FillPoly( thePoly,&qd.black);    
  2419.             }
  2420.             else
  2421.             {                                /*    fifth triangle    */
  2422.                 MoveTo((**w_objs_hndl).bg_object[14]._3dPt_BG[0].x_point -offset.h,
  2423.                         (**w_objs_hndl).bg_object[14]._3dPt_BG[0].y_point -offset.v);
  2424.                 LineTo((**w_objs_hndl).bg_object[14]._3dPt_BG[1].x_point -offset.h,
  2425.                         (**w_objs_hndl).bg_object[14]._3dPt_BG[1].y_point -offset.v);
  2426.                 LineTo((**w_objs_hndl).bg_object[14]._3dPt_BG[2].x_point -offset.h,
  2427.                         (**w_objs_hndl).bg_object[14]._3dPt_BG[2].y_point -offset.v);
  2428.                 LineTo((**w_objs_hndl).bg_object[14]._3dPt_BG[0].x_point -offset.h,
  2429.                         (**w_objs_hndl).bg_object[14]._3dPt_BG[0].y_point -offset.v);
  2430.             }
  2431.         }
  2432.         if(    (**w_objs_hndl).bg_object[15]._3dPt_BG[0].z_point < 0 &&
  2433.             (**w_objs_hndl).bg_object[15]._3dPt_BG[1].z_point < 0 &&
  2434.             (**w_objs_hndl).bg_object[15]._3dPt_BG[2].z_point < 0)
  2435.         {
  2436.             if(doPers)
  2437.             {
  2438.                 for(j = 0;j <= 2;j++)            /*    0••2 cause 3 points for a triangle    */
  2439.                 {
  2440.                     preplot3[j][0] = (**w_objs_hndl).bg_object[15]._3dPt_BG[j].x_point -offset.h;
  2441.                     preplot3[j][1] = (**w_objs_hndl).bg_object[15]._3dPt_BG[j].y_point -offset.v;
  2442.                     preplot3[j][2] = (**w_objs_hndl).bg_object[15]._3dPt_BG[j].z_point;
  2443.                     preplot3[j][3] = (**w_objs_hndl).bg_object[15]._3dPt_BG[j].no_point;
  2444.                 }
  2445.                 /*    transform to relative VRP    */
  2446.                 for(j = 0;j <= 2;j++)        /*    initialize xForm3    */
  2447.                 {
  2448.                     for(k = 0;k <= 3;k++)
  2449.                     {
  2450.                         xForm3[j][k] = 0.0;                
  2451.                     }
  2452.                 }
  2453.                         /*    set VRP    */
  2454.         
  2455.                 VRPxform[0][3] = -1.0 * xVan;
  2456.                 VRPxform[1][3] = -1.0 * yVan;
  2457.  
  2458.                 for(j = 0;j <= 2;j++)
  2459.                 {
  2460.                     for(k = 0;k <= 3;k++)
  2461.                     {
  2462.                         for(i = 0;i <= 3;i++)
  2463.                         {
  2464.                             xForm3[j][k] += VRPxform[k][i] * preplot3[j][i];                
  2465.                         }
  2466.                     }
  2467.                 }                /* first create persMat    */
  2468.                 for(j = 0;j <= 2;j++)
  2469.                 {
  2470.                     for(k = 0;k <= 3;k++)
  2471.                     {
  2472.                         for(m = 0;m <= 3;m++)
  2473.                         {
  2474.                             if(m == k)    pers3Mat[j][k][m] = 1;
  2475.                             else        pers3Mat[j][k][m] = 0;
  2476.                         }
  2477.                     }
  2478.                 }
  2479.                 for(j = 0;j <= 2;j++)        /*    cause three vertices in the object    */
  2480.                 {
  2481.                     Wtemp3[j] = (xForm3[j][2]) / zScale;                /*    tenth try    */
  2482.                 }
  2483.                 for(m = 0;m <= 2;m++)
  2484.                 {
  2485.                     for(k = 0;k <= 2;k++)
  2486.                     {
  2487.                         newPers3Vect[m][k] = 0;
  2488.                     }
  2489.                     newPers3Vect[m][3] = 1;
  2490.                 }
  2491.                 for(m = 0;m <= 2;m++)            /*      *-------------- vertice point    */
  2492.                 {                                /*    |  *----------- column        */
  2493.                     for(k = 0;k <= 2;k++)        /*      |  |  *-------- vertice point */
  2494.                     {                            /*      v  v  v                        */
  2495.                         newPers3Vect[m][k] =   xForm3[m][k]/(Wtemp3[m]);
  2496.                     }
  2497.                 }
  2498.                 /*    transform back from VRP    */
  2499.  
  2500.                 VRPxform[0][3] = xVan;
  2501.                 VRPxform[1][3] = yVan;
  2502.                 
  2503.                 for(j = 0;j <= 2;j++)
  2504.                 {
  2505.                     for(k = 0;k <= 3;k++)
  2506.                     {
  2507.                         xForm3[j][k] = 0;                
  2508.                     }
  2509.                 }
  2510.  
  2511.                 for(j = 0;j <= 2;j++)
  2512.                 {
  2513.                     for(k = 0;k <= 3;k++)
  2514.                     {
  2515.                         for(i = 0;i <= 3;i++)
  2516.                         {
  2517.                             xForm3[j][k] += VRPxform[k][i] * newPers3Vect[j][i];                
  2518.                         }
  2519.                     }
  2520.                 }
  2521.                 for(j = 0;j <= 2;j++)
  2522.                 {
  2523.                     for(k = 0;k <= 3;k++)
  2524.                     {
  2525.                         newPers3Vect[j][k] = xForm3[j][k];
  2526.                     }
  2527.                 }
  2528.                 MoveTo(newPers3Vect[0][0],newPers3Vect[0][1]);
  2529.                 thePoly = OpenPoly();
  2530.                 LineTo(newPers3Vect[1][0],newPers3Vect[1][1]);
  2531.                 LineTo(newPers3Vect[2][0],newPers3Vect[2][1]);
  2532.                 LineTo(newPers3Vect[0][0],newPers3Vect[0][1]);
  2533.                 ClosePoly();
  2534.                 FillPoly( thePoly,&qd.gray);
  2535.             }
  2536.             else
  2537.             {                    /*    sixth triangle    */
  2538.                 MoveTo((**w_objs_hndl).bg_object[15]._3dPt_BG[0].x_point -offset.h,
  2539.                         (**w_objs_hndl).bg_object[15]._3dPt_BG[0].y_point -offset.v);
  2540.                 LineTo((**w_objs_hndl).bg_object[15]._3dPt_BG[1].x_point -offset.h,
  2541.                         (**w_objs_hndl).bg_object[15]._3dPt_BG[1].y_point -offset.v);
  2542.                 LineTo((**w_objs_hndl).bg_object[15]._3dPt_BG[2].x_point -offset.h,
  2543.                         (**w_objs_hndl).bg_object[15]._3dPt_BG[2].y_point -offset.v);
  2544.                 LineTo((**w_objs_hndl).bg_object[15]._3dPt_BG[0].x_point -offset.h,
  2545.                         (**w_objs_hndl).bg_object[15]._3dPt_BG[0].y_point -offset.v);
  2546.             }
  2547.         }
  2548.         if(obj_type == T_BACKGRND_OBJ)
  2549.         {
  2550.             if(    (**w_objs_hndl).bg_object[16]._3dPt_BG[0].z_point < 0 && (**w_objs_hndl).bg_object[16].alive)
  2551.             {
  2552.                 _left = (**w_objs_hndl).bg_object[16]._3dPt_BG[0].x_point;
  2553.                 _top = (**w_objs_hndl).bg_object[16]._3dPt_BG[0].y_point;
  2554.                 _right = _left + 32;
  2555.                 _bottom = _top + 32;
  2556.                 SetRect(&gFirstCalcIcon,_left,_top,_right,_bottom);
  2557.                 icon_hndl = GetResource('ICON', FIRST_CALC_ID);
  2558.                 PlotIcon(&gFirstCalcIcon, icon_hndl);
  2559.             }
  2560.             if(    (**w_objs_hndl).bg_object[17]._3dPt_BG[0].z_point < 0 && (**w_objs_hndl).bg_object[17].alive)
  2561.             {
  2562.                 _left = (**w_objs_hndl).bg_object[17]._3dPt_BG[0].x_point;
  2563.                 _top = (**w_objs_hndl).bg_object[17]._3dPt_BG[0].y_point;
  2564.                 _right = _left + 32;
  2565.                 _bottom = _top + 32;
  2566.                 SetRect(&gSecondCalcIcon,_left,_top,_right,_bottom);
  2567.                 icon_hndl = GetResource('ICON', SECOND_CALC_ID);
  2568.                 PlotIcon(&gSecondCalcIcon, icon_hndl);            
  2569.             }
  2570.             if(    (**w_objs_hndl).bg_object[18]._3dPt_BG[0].z_point < 0 && (**w_objs_hndl).bg_object[18].alive)
  2571.             {
  2572.                 _left = (**w_objs_hndl).bg_object[18]._3dPt_BG[0].x_point;
  2573.                 _top = (**w_objs_hndl).bg_object[18]._3dPt_BG[0].y_point;
  2574.                 _right = _left + 32;
  2575.                 _bottom = _top + 32;
  2576.                 SetRect(&gThirdCalcIcon,_left,_top,_right,_bottom);
  2577.                 icon_hndl = GetResource('ICON', THIRD_CALC_ID);
  2578.                 PlotIcon(&gThirdCalcIcon, icon_hndl);
  2579.             }
  2580.             if(    (**w_objs_hndl).bg_object[19]._3dPt_BG[0].z_point < 0 && (**w_objs_hndl).bg_object[19].alive)
  2581.             {
  2582.                 _left = (**w_objs_hndl).bg_object[19]._3dPt_BG[0].x_point;
  2583.                 _top = (**w_objs_hndl).bg_object[19]._3dPt_BG[0].y_point;
  2584.                 _right = _left + 32;
  2585.                 _bottom = _top + 32;
  2586.                 SetRect(&gFourthCalcIcon,_left,_top,_right,_bottom);
  2587.                 icon_hndl = GetResource('ICON', FOURTH_CALC_ID);
  2588.                 PlotIcon(&gFourthCalcIcon, icon_hndl);
  2589.             }
  2590.             if(    (**w_objs_hndl).bg_object[20]._3dPt_BG[0].z_point < 0 && (**w_objs_hndl).bg_object[20].alive)
  2591.             {
  2592.                 _left = (**w_objs_hndl).bg_object[20]._3dPt_BG[0].x_point;
  2593.                 _top = (**w_objs_hndl).bg_object[20]._3dPt_BG[0].y_point;
  2594.                 _right = _left + 32;
  2595.                 _bottom = _top + 32;
  2596.                 SetRect(&gFifthCalcIcon,_left,_top,_right,_bottom);
  2597.                 icon_hndl = GetResource('ICON', FIFTH_CALC_ID);
  2598.                 PlotIcon(&gFifthCalcIcon, icon_hndl);
  2599.             }
  2600.             if(    (**w_objs_hndl).bg_object[21]._3dPt_BG[0].z_point < 0 && (**w_objs_hndl).bg_object[21].alive)
  2601.             {
  2602.                 _left = (**w_objs_hndl).bg_object[21]._3dPt_BG[0].x_point;
  2603.                 _top = (**w_objs_hndl).bg_object[21]._3dPt_BG[0].y_point;
  2604.                 _right = _left + 32;
  2605.                 _bottom = _top + 32;
  2606.                 SetRect(&gSixthCalcIcon,_left,_top,_right,_bottom);
  2607.                 icon_hndl = GetResource('ICON', SIXTH_CALC_ID);
  2608.                 PlotIcon(&gSixthCalcIcon, icon_hndl);
  2609.             }
  2610.         }
  2611.     }
  2612.     SetPort( oldPort );    /* can set breakpoint here */
  2613. }  /*  end of draw_object()    **/